Changes the contents of an already existing variable. Variables are used as storage mechanism to store data while a task is running. Once a variable is created, its contents can be displayed at runtime by placing the variable name in percent signs (e.g., %myvarname% will automatically be converted it it's contents at runtime). For more information see Variables.
To enter Set Variable properties
In the Available Actions pane, open the Variables folder and double-click the Set Variable action or drag it into the Steps pane.
In the Variable Name box, select the variable to populate.
In the New Value box, enter the value for the variable. If you want to use an expression, click the percent sign (%) and use the Expression Builder to create it.
If you do not want the initial value visible in the AML file, select Disguise initial value. If this is selected, the initial value displays as random characters in the AML file.
To set the Description tab properties, refer to Description Tab Options.
To set the Error Causes and On Error tab properties, refer to Step Error Handling.
When finished, click OK to save settings and close the properties dialog box.
Declaration
<AMSET VARIABLENAME="text (variable name)">text (value to set)</AMSET>
OR
<AMSET VARIABLENAME="te">AM125QfdSMYkv0zoNy+RdvlmA==aME</AMSET>
Example 1 - A Set Variable action used to change the initial value of an existing variable.
<AMVARIABLE NAME="myVariable">AutoMate</AMVARIABLE>
<AMSHOWDIALOG WINDOWTITLE="CURRENT VALUE">The current value of myVariable is:
%myVariable%</AMSHOWDIALOG>
<AMSET VARIABLENAME="myVariable">Business Process Automation</AMSET>
<AMSHOWDIALOG WINDOWTITLE="NEW VALUE">The new value of myVariable is:
%myVariable%</AMSHOWDIALOG>
Example 2 - A Set Variable action used to populate a value into a variable created with no initial value.
<AMVARIABLE NAME="myVariable"></AMVARIABLE>
<AMSHOWDIALOG WINDOWTITLE="CURRENT VALUE">The current value of myVariable is:
%myVariable%</AMSHOWDIALOG>
<AMSET VARIABLENAME="myVariable">Business Process Automation</AMSET>
<AMSHOWDIALOG WINDOWTITLE="NEW VALUE">The new value of myVariable is:
%myVariable%</AMSHOWDIALOG>
Example 3 - Variable multiplication - This task describes how to multiply the initial value of two variables using the Set Variable action and display the results in a message box.
<AMSHOWDIALOG>This task describes how to multiply the initial value of two variables using the
‘Set Variable’ action and display the results in a message box. This action changes
the contents of an already existing variable. As with all parameters, this value
may be literal or an expression (if surrounded by percent signs). This will work with
other calculations as well (i.e. addition "+", subtraction "-", division "/").</AMSHOWDIALOG>
<AMVARIABLE NAME="var1">30</AMVARIABLE>
<AMVARIABLE NAME="var2">10</AMVARIABLE>
<AMVARIABLE NAME="var3"></AMVARIABLE>
<AMSET VARIABLENAME="var3">%var1 * var2%</AMSET>
<AMSHOWDIALOG>%var1% multiplied by %var2% results is %var3%</AMSHOWDIALOG>
See Also: Create Array, Create Object, Create Variable, Decrement Variable, Define Type, Increment Variable, ReDim Array, Set Variable
Property |
Type |
Required |
Default |
Markup |
Description |
Variable to increment |
Text |
Yes |
(Empty) |
VARIABLENAME="thecurrentdate" |
The name of the variable to change. |
Value |
Text |
Yes |
(Empty |
VALUE="The current date is %Now()%" |
The value that the variable should be changed to. As with all parameters, this value may be literal or an expression (if surrounded by percent % signs). |
All variables must be created before they can be used. This is done using the Create Variable action. Once created, variables can be set using the Set Variable action, or by certain actions that support populating variables. To get data out of the variables in any action parameter, surround the variable name with percentage % signs (i.e. %varname%). Remember not to use percentage signs when specifying the name of a variable to populate, percentage signs are only needed to get data out.