Create Array Action

Description

Creates a one or two dimensioned array for storing multiple items in sequential order with the same variable name. An array is a special type of Automated Workflow 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 first name, last name, 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.

Declaration

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

Example

<!--- 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 dimensions (requires a folder called c:\test\ with a few files in it. Array has a row for each file in the folder. 3 columns 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>

General Tab Parameters

Array Name: 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). Click the Expression Builder icon to build and insert an expression or variable.

Text, Required
MARKUP: NAME="myarray"

Rows: 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.

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

Columns: 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.

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

Description: 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.

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

Advanced Tab Parameters

Variable type: Causes the variable to assume a specific type.

  • Auto: Variable will auto-detect whether it contains a number or text. 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 its 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 its contents. If an operation is attempted that is only valid for numbers, an error will be thrown.

Text, Required
MARKUP: TYPE="number"

Notes

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.

See Also

Set Variable