Josef_Scharl_103

How to mask literals containing an ampersand character (&) in Automic script?

Discussion created by Josef_Scharl_103 on Mar 17, 2017

Whenever an ampersand sign (&) is used in a script literal, it happens that the Automation Engine interprets it as script variable and try to resolve it during the processing. 

Example:

The literal 'ABC&DEF' should be used as value of a script variable. Later on this variable should be used. In this simple example just for a print statement:

 

:set &value1# = 'ABC&DEF'
:p '&value1#'

 

The Engine tries to resolve '&DEF', which will lead in the error:

 

U00021719 Syntax error in object 'SCRI.VARA.MASK', line '00001'. 'U01001308 Variable 'DEF' has not yet been defined.'.

 

 

This can be solved eayily by masking the ampersand sign (&) with another one, so just use the & character twice:

 

 

 

 

:set &value1# = 'ABC&&DEF'
:p '&value1#'

Now the script will work, the activation protocol will look like:

 

U00020408 ABC&DEF

 

 

 

There is also an example in the documentation “Automic Scripting Guide” – “Script Variables” – “Lesson 3”:

https://docs.automic.com/documentation/webhelp/english/AWA/12.0/DOCU/12.0/AWA%20Guides/help.htm#AE_AWA_Source/Script/ucacvb.htm%3FTocPath%3DAutomic%2520Scripting%2520Guide%7CIntroduction%7CFirst%2520Steps%7C_____5

Outcomes