Create Variable

Declaration

<AMVARIABLE NAME="text" READONLY="yes/no" PRIVATE="yes/no" ISPARAMETER="yes/no" DESCRIPTION="text">text</AMVARIABLE>

See Also

Create Array, Create Object, Decrement Variable, Define Type, Increment Variable, ReDim Array, Set Variable

Description

Creates an AutoMate 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.

Practical Usage

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 subsequent steps. 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.

Parameters

General Properties

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 window of the Task Builder under the Variables tab.

 

Advanced Properties

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:

  • Auto: Variable will auto-detect whether it contains a number or text. The variable will adapt to the proper type when possible depending on the operation being performed.

  • Text: Variable will always be treated as text regardless of it's contents. If an operation is attempted that is only valid for numbers, an error will be thrown.

  • Number: Variable will always be treated as a number regardless of it's contents. If an operation is attempted that is only valid for numbers, an error will be thrown.

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.

 

Description Properties

The Description tab allows you to customize the text description of any step as it appears in the Task Builder's Steps Pane.

More on setting custom step description

Error Causes Properties

The Error Causes tab properties allows you to instruct a task step to react only to specific errors or ignore certain errors that should cause it to fail.

More on Error Causes properties

On Error Properties

The On Error tab properties lets you determine what the task should do if a particular step encounters an error as defined in the Error Causes properties.

More about On Error properties

Additional Notes

Expressions, Variables and Functions

All text fields allow the use of expressions such as variables, functions or AutoMate extended functions, which can be entered by surrounding the expression in percentage signs (example: %FileDateTime(myVar)% or %myVar%, %Left('Text',2)%). To help construct these expressions, you can open Expression Builder from these fields by clicking the Insert Expression (%) button or by pressing F2.

More on expressions

More on variables

More on function

More on extended functions
More on the expression builder

Example

NOTE: The code below can be copied and pasted directly into the Steps pane of the Task Builder.

 

Description: This sample task performs a Ceate 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>

 

↑ Top of Page