Reinitializing Variables
- Updated: 2020/05/11
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:
- In the Workbench, drag a Variable Operation command into the task.
- Select the User Variables option.
- Under "Specify Variable," select the variable that you want to reinitialize.
- Select the Reinitialize radio button.
- In the "Specify value" field, browse to select a new text file for the variable to reinitialize the value.
- Click Save. Any previous values for this variable will be overwritten.
Reinitializing List Variables
To reinitialize a list type variable, follow these steps:
- In the Workbench, drag a Variable Operation command into the task.
- Select the User Variables option.
- Under "Specify Variable," select the variable that you want to reinitialize.
- Select the Reinitialize radio button.
- In the "Specify value" field, type in new values or browse to locate a new text file.
- 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:
- In the Workbench, drag a Variable Operation command into the task.
- Select the User Variables option.
- 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.
- Select the Reinitialize radio button.
- 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.
- In the "Specify value" field, enter values or insert another variable by pressing the F2 function key.
- 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:
- In the Workbench, drag a Variable Operation command into the task.
- Select the User Variables option.
- Under "Specify Variable," select the variable that you want to reinitialize.
- Select the Reinitialize radio button.
- In the "Specify value" field, specify new values for the number range or string.
- Click Save. Any previous values for this variable will be overwritten.
Use Case Scenarios
Example 1:
Type: List Source: Read from text Reinitialize
- 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
-
Variable Operation: Reinitialize $RDlsttxt$
-
Start Loop "List Variable $RDlsttxtquot;
- Comment: This Loop will run 4 times as 'List read from text file variable has 4 entries.
- Comment: The following command will send emails to the address IDs listed in the above Read from text file -List variable.
-
Send Email: Subject "Automation Anywhere finished executing the task." with Attachment(s).
-
Message Box: "Email to '$RDlsttxt#39; has been sent sucessfully."
-
End Loop
Example 2:
Type: Array Source: Read from Excel
- Comment: Reinitializing the Array Source: read from excel file (ArrayExl) with the CSV file extracted from the website.
-
Variable Operation: Reinitialize $ArrayExl$
-
Variable Operation: $ArrayRows($ArrayExl$)$ To $Row$
-
Start Loop "$Rowquot; Times
-
If $Counter$ Equal To (=) "1" Then
- Comment: To skip the header title of the csv extracted from the website
-
Continue
-
End If
-
Execute SQL Statement: 'Insert into Ebayphilosophy (BookTitle,cost) values ("$ArrayExl($Counter$,1)quot;,'$ArrayExl($Counter$,2)#39;)' Session: 'Default'
-
End Loop