Create Array Action Icon

Create Array

Declaration

AMARRAY NAME="text" ROWS="text" COLUMNS="text" DEPTH="text" DESCRIPTION="text" ISPARAMETER="YES" PRIVATE="YES" />

See Also

 Create Object | Create Variable | Define Type | Increment Variable | ReDim Array | Return | Set Variable

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

Parameters

General Properties

Property

Type

Required

Default

Markup

Description

Array Name

Text

Yes

(Empty)

NAME="myarray"

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

Number

Yes

0

ROWS="4"

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

Number

Yes

0

COLUMNS="4"

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

No

(Empty)

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 Variables information window.

Advanced Properties

Property

Type

Required

Default

Markup

Description

Variable Type

Text (options)

No

Auto

TYPE="TEXT"

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

  • 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 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.

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 lets you 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 & Functions

A percent sign is used as a special character in AutoMate to indicate the beginning and end of an expression. This allows variables, functions and other expressions to be entered in any text parameter of a task's properties. For example: %1+1% inside a task will resolve to 2 at runtime. A more elaborate example is %FileDateTime(myFile)% which results to the date/time of myFile. To help construct expressions, you can open Expression Builder by clicking the Insert Expression (%) button or by pressing F2.

More on expressions

More on variables

More on functions

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.

 

Sample 1 - Simple example

 

<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>

<AMSHOWDIALOG MESSAGE="%myarray(1)%; %myarray(2)%; %myarray(3)%" />

 

 

Sample 2 - 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\')%" />

<AMLOOP TYPE="FOLDER" FOLDER="c:\test\" RESULTVARIABLE="thefilename">

     <AMINCREMENTVARIABLE RESULTVARIABLE="counter" />

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

</AMLOOP>

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

     <AMSHOWDIALOG MESSAGE="%myarray(counter)%" />

</AMLOOP>

 

 

 

Sample 3 - 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 columns hold filename, size and date).

 

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

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

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

<AMLOOP TYPE="FOLDER" 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">

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

File Size: %myarray(counter, 2)%

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

</AMLOOP>

 

↑ [Return to Top]