Reinitializing Variables

When you create user variables and use them within automation tasks, you need to reinitialize them each time you use them.

You can reinitialize any type of user variable, including:

  • Value variables (Only read from txt type)
  • List variables
  • Array variables
  • Random variables

Reinitializing Value Variables

To reinitialize a value type variable, follow these steps:

  1. In the Workbench, drag a Variable Operation command into the task.
  2. Select the User Variables option.
  3. Under "Specify Variable," select the variable that you want to reinitialize.
  4. Select the Reinitialize radio button.
  5. In the "Specify value" field, browse to select a new text file for the variable to reinitialize the value.
  6. Click Save. Any previous values for this variable will be overwritten.

Reinitializing List Variables

To reinitialize a list type variable, follow these steps:

  1. In the Workbench, drag a Variable Operation command into the task.
  2. Select the User Variables option.
  3. Under "Specify Variable," select the variable that you want to reinitialize.
  4. Select the Reinitialize radio button.
  5. In the "Specify value" field, type in new values or browse to locate a new text file.
  6. Click Save.

Only the new values that are specified will be assigned. Any previous values for this variable will be overwritten.

Reinitializing Array Variables

Several options are available for reinitializing array variables.

To reinitialize an array type variable, follow these steps:

  1. In the Workbench, drag a Variable Operation command into the task.
  2. Select the User Variables option.
  3. Under "Specify Variable," select the array variable from the list of user variables that are defined for the task. The variable type and source is displayed.
  4. Select the Reinitialize radio button.
  5. Specify new dimensions. For example, Row 2 and Column 2. You can also specify other variables to be inserted here by pressing the F2 function key and selecting the variable.
  6. In the "Specify value" field, enter values or insert another variable by pressing the F2 function key.
  7. Click Save.

Restrictions and Usage Rules:

  • If the rows and columns are numeric, you can use the Initialize Values button to insert new values. In this case, both the structure and values for the array are completely redefined.
  • For an array having source type Excel, you can reinitialize the entire row, column, range, or all of the cells.
  • For an array having source type of Excel or CSV file, you need to specify a path in order to reinitialize it.

  • The Open File option is enabled only when you specify a valid file path.
  • For an array having a Database source type, you can specify connection properties to a new database with its SQL query.

Reinitializing Random Variables

To reinitialize a random variable, follow these steps:

  1. In the Workbench, drag a Variable Operation command into the task.
  2. Select the User Variables option.
  3. Under "Specify Variable," select the variable that you want to reinitialize.
  4. Select the Reinitialize radio button.
  5. In the "Specify value" field, specify new values for the number range or string.
  6. Click Save. Any previous values for this variable will be overwritten.

Use Case Scenarios

Example 1:

Type: List Source: Read from text Reinitialize

  1. Comment: Reinitialize Variable Type: List, Source: Read from text file having this RDlsttxt =https://support.automationanywhere.com, testing@gmail.com, sales@automationanywhere.com, buynow@automationanywhere.com
  2. Variable Operation: Reinitialize
    $RDlsttxt$
  3. Start Loop "List Variable
    $RDlsttxt
    quot;
  4. Comment: This Loop will run 4 times as 'List read from text file variable has 4 entries.
  5. Comment: The following command will send emails to the address IDs listed in the above Read from text file -List variable.
  6. Send Email: Subject "Automation
    Anywhere finished executing the task." with
    Attachment(s).
  7. Message Box: "Email to
    '$RDlsttxt
    #39; has been sent sucessfully."
  8. End Loop

Example 2:

Type: Array Source: Read from Excel

  1. Comment: Reinitializing the Array Source: read from excel file (ArrayExl) with the CSV file extracted from the website.
  2. Variable Operation: Reinitialize
    $ArrayExl$
  3. Variable Operation:
    $ArrayRows($ArrayExl$)$ To $Row$
  4. Start Loop "$Row
    quot; Times
  5. If $Counter$ Equal To (=) "1"
    Then
  6. Comment: To skip the header title of the csv extracted from the website
  7. Continue
  8. End If
  9. Execute SQL Statement: 'Insert
    into Ebayphilosophy (BookTitle,cost) values
    ("$ArrayExl($Counter$,1)
    quot;,'$ArrayExl($Counter$,2)
    #39;)' Session: 'Default'
  10. End Loop