Variable - Create

Declaration

<AMVARIABLE NAME="text" VALUE="text" DESCRIPTION="text" TYPE="text (options)" READONLY="YES/NO" PRIVATE="YES/NO" ISPARAMETER="YES/NO" />

Description:

Creates an variable, which can be used to store dynamic values for use in subsequent steps. The value of a variable can be specified at runtime by placing the variable name in percent signs (e.g.,%myvarname% will automatically be converted to its value at runtime). For more information, see Variables.

Practical Usage

Variables must first be created in order to use them in a task. This activity is ideally used in the beginning steps of a task to create one or more required variables in order for subsequent steps to reference them during runtime. Once a variable is created, its contents can be viewed, set or modified within any step parameter.

General

Property

Type

Required

Default

Markup

Description

Variable name

Text

Yes

(Empty)

NAME="theVarName"

The name of the variable to create. Variable names are not case sensitive, however, they must contain only alphanumeric characters, must start with a letter and cannot contain spaces. It is good practice to select a name that is descriptive of what the variable holds. For example, if a variable holds the size of a shoe, then name it 'ShoeSize' or 'theSize' 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

Property

Type

Required

Default

Markup

Description

Variable Type

Text (options)

No

Auto

  1. TYPE="auto"

  2. TYPE="text"

  3. TYPE="number"

Causes the variable to assume a specific type. The available options are:

  • Auto (default) - 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

Error Causes

On Error

Examples

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

Sample 1: This sample task creates a variable named "theSampleVariable" with the value of "Hello world!" which is displayed in a message box.

 

<AMVARIABLE NAME="theSampleVariable">Hello world!</AMVARIABLE>

<AMSHOWDIALOG>Variable Value - %theSampleVariable%</AMSHOWDIALOG>

 

Sample 2: This sample task displays how variables can be used interactively. A selection dialog appears allowing the user to select one or more list items. Thereafter, a message box displays all of the items selected.

 

<AMVARIABLE NAME="var1">First Name</AMVARIABLE>

<AMVARIABLE NAME="var2">Last Name</AMVARIABLE>

<AMVARIABLE NAME="var3">Address</AMVARIABLE>

<AMVARIABLE NAME="var4">Phone Number</AMVARIABLE>

<AMVARIABLE NAME="theVars" />

<AMSHOWDIALOG ACTIVITY="select" MESSAGETEXT="Please select one or more items below." RESULTVARIABLE="theVars" LISTTYPE="checkbox" ITEMS="%var1%,%var2%,%var3%,%var4%" VALUES="First Name,Last Name,Address ,Phone" WINDOWTITLE="Sample Item Selection Task " ONCANCEL="stop" FORCESELECT="NO" MULTIPLE="YES" />

<AMSHOWDIALOG WINDOWTITLE="Selected Items" BUTTONS="ok_cancel" ONSECONDBUTTONCLICK="stop">You selected the following item(s):

%theVars%

</AMSHOWDIALOG>