search cancel

SCRIPTING : IF... :ELSE... :ENDIF -- Trailing blank spaces are not considered in string comparisons

book

Article ID: 229794

calendar_today

Updated On:

Products

CA Automic Workload Automation - Automation Engine

Issue/Introduction

he comparison of strings does not return the same result wether the ' ' are on the right part or on left part of the string chain.

If you run the following script sequence:

{code} 
:PRINT "================================="
:PRINT "CONTROLE ' ' removed only right side"
:PRINT "================================="
: IF '  TUTU' <> '  TUTU  '
:    PRINT "[RAW STRING CHECK ] - '  WORD' AND '  WORD ' DIFFERENT!"
:ELSE
:    PRINT "[RAW STRING CHECK] - '  WORD' AND '  WORD ' NOT DIFFERENT!."
: ENDIF
:PRINT "================================="
:PRINT "CONTROLE ' ' removed only Left side"
:PRINT "================================="
: IF 'WORD ' <> '  WORD '
:    PRINT "[RAW STRING CHECK ] - 'WORD ' AND '  WORD ' DIFFERENT!"
:ELSE
:    PRINT "[RAW STRING CHECK] - 'WORD ' AND '  WORD ' NOT DIFFERENT!"
: ENDIF
{code} 

the report will contain the following result

{code} 
=================================
CONTROLE ' ' removed only right side
=================================
[RAW STRING CHECK] - '  WORD' AND '  WORD ' NOT DIFFERENT!.
=================================
CONTROLE ' ' removed only Left side
=================================
[RAW STRING CHECK ] - 'WORD ' AND '  WORD ' DIFFERENT!
{code} 

Surprisingly, the result of this logical test is not the same. The automate considers '  TUTU' and '  TUTU  ' as identical.

 

Environment

Release : 12.0,12.1,12.2,12.3,21.0

Component : AUTOMATION ENGINE

Resolution

This behavior is as expected by design

===============================

As stated in the documentation of :IF... :ELSE... :ENDIF since at least v11.2

https://docs.automic.com/documentation/webhelp/english/AWA/12.0/DOCU/12.0/AWA%20Guides/help.htm#AE_AWA_Source/Script/ucaadp.htm

https://docs.automic.com/documentation/webhelp/english/AWA/12.2/DOCU/12.2/AWA%20Guides/help.htm#Script/Reference/IFELSE.htm?Highlight=if

https://docs.automic.com/documentation/webhelp/english/AA/21.0/DOCU/21.0/Automic%20Automation%20Guides/Content/Script/Reference/IFELSE.htm?Highlight=if

 

Quote: "Trailing blank spaces are not considered in string comparisons."

==================================