Variable update action (<varupdate> element)

The <varupdate> element stores a value into a variable. During macro playback the macro runtime performs the action by storing the specified value into the specified variable.

You must specify:
  • The name of a variable
  • The value that you want to store into the variable

This action can be specified using the VME, see Update macro variable action, and using the AME, see Variable update action.

You can also use the Variable update action in a <description> element (see Processing a Variable update action in a description).

The value can be an arithmetic expression and can contain variables and calls to imported methods. If the value is an expression, then during macro playback the macro runtime evaluates the expression and stores the resulting value into the specified variable.

The Variable update action works like an assignment statement in a programming language. In a Java™ program you could write assignment statements such as:
boolVisitedThisScreen = true;
intVisitCount = intVisitCount + 1;
dblLength = 32.4;
strAddress ="123 Hampton Court";
With the Variable update action you type the left side of the equation (the variable) into the variable name field in the macro editor and type the right side of the equation (the value) into the value field. To create the equivalents of the Java assignment statements above, you would use the values shown in Table 1:
Table 1. Example of variable names and values
In the variable name field: In the value field:
$boolVisitedThisScreen$ true
$intVisitCount$ $intVisitCount$+1
$dblLength$ 32.4
$strAddress$ '123 Hampton Court'

The value that you provide must belong to the correct data type for the context or be convertible to that type (see Automatic data type conversion).

The Variable update action is useful because:
  • The entity in the Value field can be an expression
  • Expressions are not evaluated until the action is performed
For more information on expressions see Data types, operators, and expressions.

For more information, see <varupdate> element.