![]() |
| |||||||
Automation Anywhere Post messages and questions related to Automation Software here. |
![]() |
| | LinkBack | Thread Tools | Display Modes |
| |||
|
Hi I currently have a loop which loops via the list variable APS-R and this works correctly. I would like to nestle this loop inside a loop which runs the existing loop twice, and thus reuse the loop actions. I have a variable (APS-SN) within this loop that I would like to be of value one on first run through of the loop, and then have a second value on the second run through of the loop. Is this possible? Many thanks David |
| |||
|
Hello David, If you have two list variables say Listvar1 and Listvar2 and you want to loop through each item of these list variables then you have two options. 1) Automation Anywhere provides you with 'Loop for List Variable' command to traverse a list variable. Here you can create a nested loop (i.e. loop inside loop). However, you cannot loop for two list variables simultaneously. To understand this scenario, please see below modal, Start Loop ListVar1 Start Loop ListVar2 End Loop End Loop In above case, task will start with ListVar1 item1 and then will loop for each item in ListVar2 (i.e. item1, item2, etc.). In second iteration, it would have ListVar1 item2 and then will loop for each item in ListVar2 (i.e. item1, item2, etc.). Hence, for each item of ListVar1 the task will loop for every item in ListVar2. 2) If you wish to loop for these two list variables simultaneously i.e. in a single loop items of both the list variables should increment then you will have to place the data in two columns of excel for e.g. Column1 would have ListVar1 items and Column2 would have ListVar2 items. Now, using Excel command (found under Applications command category), open that excel file (using Open Spreadsheet option), get all the data using Get Multiple Cells option and using 'Loop for each row in an Excel dataset' command get the data using $Excel Column$ variable. Whenever you have retrieved a range of cells from excel using Excel-> Get Cells->Get Multiple Cells., the rows and columns of the range are stored in the System Variable $Excel Column$ . Let's say you retrieved a range of cells from excel that have 2 columns. You can access the two columns of the table by calling $Excel Column(1)$, $Excel Column(2). For your reference, we have attached a sample task in loop.zip. Please copy attached .atmn file under location, 'C:\...\My Documents\Automation Anywhere\Automation Anywhere\My Tasks' folder. Copy Book1.xls under C:\ and run the task. Hope that helps. |
| |||
|
Good Afternoon Thank you for the example. I'm not sure that I explain myself, correctly. I would like a loop which runs twice; first time the variable APS-L is equal to A and I would like this passed to the loop with runs through a list variable (I have this loop working), once the loop which runs through the list variable completes the loop the first loop moves onto the second loop and APS-L becomes equal to B, and the loop which runs through the list variable loop is reused. A structure of: Loop If first loop: APS-L = A If second loop: APS-L = B Loop from list variable APS-L = A (for first loop) Details from .txt Loop End Back to first, APS-L is know = B Many thanks David |
| |||
|
Hello, We have attached a sample task that shows how you can use the nested loop. To run this task, . Please copy attached .atmn file under location, 'C:\...\My Documents\Automation Anywhere\Automation Anywhere\My Tasks' folder. . Copy .xls and .txt file under C:\. Before running this task, please follow below mentioned steps to create a list variable, InnerLoop that reads value from a text file. 1. Go to Tools->Variable Manager in Automation Anywhere. 2. Click on 'Add New Variable'. 3. In 'Name' field, enter variable name i.e. InnerLoop 4. Select 'Read from text file' radio button or option. 5. In 'Value' field, specify the path of text file i.e c:\Temp.txt. 6. Press 'Save' button. 7. Press 'Ok' button. Note: Variables are case-sensitive. This task would show you the outer loop and inner loop values in a message box. Hope that helps. |
![]() |
| Thread Tools | |
| Display Modes | |
| |