Creates a variable, which can be used to store dynamic values for use in subsequent steps. Variables are used as a storage mechanism to store data while a task is running. Once a variable is created, its contents can be viewed, set or modified within any step parameter. The value of a variable can be specified at runtime by placing the variable name in percent signs (i.e. %myvarname% will automatically be converted to its contents at runtime).
For more information, see Variables.
To set Create Variable properties
In the Available Actions pane, open the Variables folder and double-click the Create Variable action or drag it into the Steps pane.
In the Variable Name box, enter a name for the variable. Be sure the name is unique and does not conflict with any BASIC scripting keywords such as date, day, week, etc. One safe way to do this is to always include identifying characters, such as VAR, in variable names (for example, DateVar).
If you want to give the variable an initial value, enter it in the Initial Value box. You can enter a literal value or click the percent sign (%) and use the Expression Builder to enter an expression.
If you want to include a description for the variable, enter it in the Description box. The description will be displayed in the Variables tab of the Task Builder debug window.
To specify additional properties, click the Advanced tab and enter the properties as described in the tables below.
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
<AMVARIABLE NAME="text" READONLY="yes/no" PRIVATE="yes/no" ISPARAMETER="yes/no" DESCRIPTION="text">text</AMVARIABLE>
Example
This example performs a Create Variable action to create a variable named "theSampleVariable" with an initial value of "Hello world!". A Message Box action is then used to display the message "%theSampleVariable%":
<AMVARIABLE NAME="theSampleVariable">Hello world!</AMVARIABLE>
<AMSHOWDIALOG>Variable Value - %theSampleVariable%</AMSHOWDIALOG>
See Also: Create Array, Create Object, Decrement Variable, Define Type, Increment Variable, ReDim Array, Set Variable
Property |
Type |
Required |
Default |
Markup |
Description |
Variable Name |
Text |
Yes |
(Empty) |
NAME="theVarName" |
The name of the variable to create. It is important that this value is unique, descriptive and does not conflict with any BASIC scripting keywords (examples of names that would cause a conflict include: date, day or week, etc.). |
Initial Value |
Text |
No |
(Empty) |
>The Current Value</AMVARIABLE> |
The value that the variable should be set to initially. As with all parameters, this value may be literal or an expression (if surrounded by percent % signs). |
Description (optional) |
Text |
No |
(Empty) |
DESCRIPTION="theDescription" |
An optional text description that describes the purpose of the variable. This information will be displayed at design time in the Debug pane of the Task Builder under the Variables tab. |
Property |
Type |
Required |
Default |
Markup |
Description |
Variable Type |
Text (options) |
No |
Auto |
TYPE="number" |
Causes the variable to assume a specific type. The available options are:
|
Variable is Read Only |
Yes/No |
No |
No |
READONLY="yes" |
If set to YES, specifies that the variable cannot be set to a value other than that specified in the Initial Value parameter. Selecting this option is equivalent to creating a task specific constant. This parameter is set to NO by default. |
Variable is private |
Yes/No |
No |
No |
PRIVATE="yes" |
If set to YES, specifies that the variable is only available to the current (or parent) task and not to any sub-tasks (or child tasks) that were started with the Start Task action. If this value is set to NO, the variable will be available to sub-tasks. Set to NO by default. |
Treat as parameter |
Yes/No |
No |
No |
ISPARAMETER="YES" |
If set to YES, specifies that the variable will only be created if it does not already exist. This is particularly useful when a task may have parameters passed to it at runtime (that is, variables of the same name will be created automatically) but a default value should be assumed when debugging and parameters are not present. |
Disguise initial value |
Yes/No |
No |
No |
>encrypted</AMVARIABLE> |
If set to YES, the value entered in the Initial Value field will be encrypted. |