Create Array Action

Declaration

<AMARRAY NAME="text" TYPE="options" ROWS="text" COLUMNS="text" DESCRIPTION="text">

See Also

Create Array Action-Setting Properties,

Description

Creates a one or two dimensioned array for storing multiple items in sequential order with the same variable name.

Practical Usage

An array is a special type of AutoMate variable used to store data with multiple rows and/or columns. It could be useful to create an array to store data read from a text file or other system containing customer data. If there were 10 customers, the array would need to have 10 rows, if the data consisted of firstname, lastname, and company name it would need 3 columns and would need to be a two dimensional array. An array can also be a simple list of text values (multiple rows only, one column), this is called a one dimensional array.

Parameters

General Tab

Array Name

Text, Required
MARKUP: NAME="myarray"

Specifies the name of the array to create. It is important that this value is unique, descriptive and does not conflict with any BASIC scripting keywords (examples of common conflicts include: date, day, week, etc).

Rows

Text, Required- Default 0
MARKUP: ROWS="4"

Specifies the number of rows that should be allocated in the variable. If only the ROWS parameter is specified and columns is omitted, a one dimensional array is created.

Columns

Text, Required- Default 0
MARKUP: COLUMNS="4"

Specifies the number of rows that should be allocated in the variable. If only the ROWS parameter is specified and columns is omitted, a one dimensional array is created.

Description

Text, optional default (none)
MARKUP: DESCRIPTION="This variable holds the date"

An optional text description that describes the purpose of the variable, this information will be displayed at design time in the Debug | Variables information window.

Advanced Tab

Variable Type

Text, Required
MARKUP: TYPE="number"

Causes the variable to assume a specific type.

The available options are:

Notes

Using Variables

All variables must be created before they can be used. This is done using the Create Variable <AMVARIABLE> action. Once created, variables can be set using the Set Variable <AMSET> action, or by certain actions that support populating variables. To get data out of the variables, in any action parameter, simply surround the variable name with percentage % signs (e.g. %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.

Custom Description

This action includes the Description tab for entering a custom step description.

More on setting custom step description

Standard Error Handling Options

This action also includes the standard Error Causes and On Error failure handling options/tabs.

More on Error Handling Options

Variables and Expressions

All text fields allow the use of expressions, which can be entered by surrounding the expression in percentage signs (example: %MYVARIABLE%, %Left('Text',2)%). To help construct these expressions, you can open Expression Builder from these fields by pressing F2.

More on variables
More on expressions

More on the expression builder

Example

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

<!--- Simple Sample --->

<AMARRAY NAME="myarray" TYPE="TEXT" ROWS="3">

<AMSET VARIABLENAME="myarray(1)">Red</AMSET>

<AMSET VARIABLENAME="myarray(2)">Blue</AMSET>

<AMSET VARIABLENAME="myarray(3)">Green</AMSET>

<AMMESSAGEBOX>%myarray(1)%

%myarray(2)%

%myarray(3)%</AMMESSAGEBOX>

 

<!--- Sample With Loops (requires a folder called c:\test\ with a few files in it. --->

<AMVARIABLE NAME="thefilename"></AMVARIABLE>

<AMVARIABLE NAME="counter"></AMVARIABLE>

<AMARRAY NAME="myarray" TYPE="TEXT" ROWS="%FileCount('c:\test\')%">

<AMLOOPFILES FOLDER="c:\test\" RESULTVARIABLE="thefilename">

     <AMINCREMENTVARIABLE RESULTVARIABLE="counter">

     <AMSET VARIABLENAME="myarray(%counter%)">%thefilename%</AMSET>

</AMLOOP>

<AMLOOP TOTALLOOPS="%UBound(myarray, 1)%" RESULTVARIABLE="counter">

     <AMMESSAGEBOX>%myarray(counter)%</AMMESSAGEBOX>

</AMLOOP>

 

<!--- Sample With Loops using two-dimentions (requires a folder called c:\test\ with a few files in it. Array has a row for each file in the folder. 3 colums hold filename, size and date. --->

<AMVARIABLE NAME="thefilename"></AMVARIABLE>

<AMVARIABLE NAME="counter"></AMVARIABLE>

<AMARRAY NAME="myarray" ROWS="%FileCount('c:\test\')%" COLUMNS="3" DESCRIPTION="array to hold filename size and date">

<AMLOOPFILES FOLDER="c:\test\" RESULTVARIABLE="thefilename">

     <AMINCREMENTVARIABLE RESULTVARIABLE="counter">

     <AMSET VARIABLENAME="myarray(%counter%, 1)">%thefilename%</AMSET>

     <AMSET VARIABLENAME="myarray(%counter%, 2)">%FileLen(thefilename)%</AMSET>

     <AMSET VARIABLENAME="myarray(%counter%, 3)">%FileDateTime(thefilename)%</AMSET>

</AMLOOP>

<AMLOOP TOTALLOOPS="%UBound(myarray, 1)%" RESULTVARIABLE="counter">

     <AMMESSAGEBOX>Filename: %myarray(counter, 1)%

File Size: %myarray(counter, 2)%

File Date: %myarray(counter, 3)%</AMMESSAGEBOX>

</AMLOOP>