This article should be considered obsolete since the release of Automate 6 as a result of its ability to create and manipulate arrays.

Automate 5 users:

In certain instances it is useful to dynamically generate variable names. To do this a variable may be created by using the contents of another variable in the name.

Please note that in order to display the variable, the GetVarValueByVarName function must be used. This is because using %test%%loopcount% creates a double-percentage sign which resolves to a literal percent sign.


<AMVARIABLE NAME="test%loopcount%">test</AMVARIABLE>
<AMMESSAGEBOX>%GetVarValueByVarName('test' &amp; loopcount)%</AMMESSAGEBOX>

Dynamic variables are useful when there is a need to store a set of data that may occur an indeterminate number of times. In the following example the task reads the lines from a file and creates a variable for each line. In the second loop the value of the dynamic variable is displayed using the Extended Function GetVarValueByVarName().

<AMFILEREAD FILE="c:\testfile.txt" RESULTVARIABLE="thedata">
<AMLOOPLIST LIST="%thedata%" RESULTVARIABLE="currentline" DELIMITER="new_line">
<AMSET VARIABLENAME="counter">%counter +1%</AMSET>
<AMVARIABLE NAME="line%counter%">%currentline%</AMVARIABLE>

<AMLOOP FROM="1" TO="%counter%" RESULTVARIABLE="theindex">
<AMMESSAGEBOX>%GetVarValueByVarName('line' &amp; theindex)%</AMMESSAGEBOX>

Until the introduction of arrays, dynamic variables provide a useful way to store multiple records of related data.

Applies To: Automate 5, Automate 6

Still have questions? We can help. Submit a case to technical support

Last Modified On:
You don't have the appropriate permissions.
No, open a new Support Case