Read and Review Automation Anywhere Documentation

Automation Anywhere Version 11.3

Close Contents

Contents

Open Contents

Using Array Type Variables

  • Updated: 5/07/2020
    • 11.3.x
    • Explore
    • Enterprise

Using Array Type Variables

An array variable is a two-dimensional variable that holds multiple values in a table of rows and columns. Arrays are very powerful for creating staging areas for data that need to be retrieved by your process as it runs.

Common uses of array variables include:

  • Extracting data from web pages
  • Extracting many rows of data from an Excel spreadsheet or a database
  • Read or write data from/to a legacy system, an ERP system, or another application
  • Filling out order forms with different fields from Excel to Database

The values can represent either text or numeric data.

After you create the variable, you can use it by inserting the variable in several of the MetaBot commands.

When the value of the variable is modified, this value is reflected in any subsequent commands that are run by the task.

Creating an Array Type Variable

You can create an array type variable in one of two ways:

Direct Assignment

When the values of an array variable need to be defined directly, you can opt to use 'Value' Array type variable. This is termed as 'Direct Assignment'.

To create an array type variable using direct assignment, follow these steps:

  1. In the Logic Editor, click the Variable Manager tab on the right side.

  2. Click on the Add button. The 'Add Variable' window is displayed.
  3. Select type 'Array'.
  4. Enter a name for the variable. The name must begin with an alphabet and should not contain spaces.
  5. Select how you want the array to be created. Default selection is 'Value' which indicates that you will define the values of this variable directly in it. .
  6. Specify the number of rows and columns in the field provided. Default values are 1 X 1.

  7. Click the Initialize Values button. The Array Value Details window is displayed based on the rows and columns provided in step 6.

  8. Enter the values for each cell.

    Tip: You can modify the array dimensions using the Add Row, Add Column, Delete Row, and Delete Column buttons.
  9. Click the Save button to save the values.
  10. Click the Save button in the Add Variable window to save the Array variable.

After the variable is saved, it is displayed in the Local Variables section of the Variable Manager.

If you do not want to specify the value of the variable at the time you create the variable, MetaBot Designer allows you to set the values of variables using a text file. This is described in the next section.

Reading from a Text File

Create an array type variable using text file assignment when you want to read values from a specified text file into the array variable while the task is running. The text file is used to define the array variable.

To create an array type variable using text file assignment, follow these steps:

  1. Determine the text file that you will use for assigning values.
    • For Rows enter the data in a new line.
    • For Columns use comma separated values.
    • Example: sports_team.txt

  2. In the Task Editor, click the Variable Manager tab on the right side.
  3. Click on the Add button. The 'Add Variable' window is displayed.

  4. Select type 'Array'.
  5. Enter a name for the variable. The name must begin with an alphabet character and should not contain spaces.
  6. Select 'Read from text file' from the list.
  7. In the Select File field, browse to the file or type the file path for the required text file. Use the Open File button to view the selected text file or to modify it.
  8. Click Save.

Inserting Array Variables in Screens and DLLs

You can insert Array Variables while creating Logic in the Logic Editor. It can be used to assign values in Screens or Dlls.

Tip: You can insert rows and columns in MetaBot Commands for a Screen. However, when used with a DLL, you can insert only a single column to the Array type variable during assignment.
  1. Adding an Array variable to a Screen - You can add an Array variable in Screens via MetaBot commands; namely Message Box, String Operation, and Variable Operation. You can also assign a variable in the Screen directly in the property window as shown:

  2. Adding an Array variable to a Dll - You can insert an Array variable while inputting values by pressing the function key 'F2' as shown:

Send Feedback