Intelligent Automation & Macro Software  

Go Back   Automation Anywhere, Inc. Forums > Products Zone > Automation Anywhere
Register FAQ Search Today's Posts Mark Forums Read

Automation Anywhere Post messages and questions related to Automation Software here.


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-26-2009, 07:41 AM
DavidCAllen DavidCAllen is offline
Junior Member
 
Join Date: Nov 2008
Posts: 7
Default Nested Loop?

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
Reply With Quote
  #2 (permalink)  
Old 02-26-2009, 08:59 AM
forumsupport forumsupport is offline
Senior Member
 
Join Date: Apr 2007
Posts: 1,342
Default

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.
Attached Files
File Type: zip Loop.zip (1.5 KB, 8 views)
Reply With Quote
  #3 (permalink)  
Old 02-27-2009, 06:34 AM
DavidCAllen DavidCAllen is offline
Junior Member
 
Join Date: Nov 2008
Posts: 7
Default

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
Reply With Quote
  #4 (permalink)  
Old 03-01-2009, 02:50 AM
forumsupport forumsupport is offline
Senior Member
 
Join Date: Apr 2007
Posts: 1,342
Default

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.
Attached Files
File Type: zip NestedLoop.zip (6.5 KB, 13 views)
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -7. The time now is 02:57 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.0.0 ©2007, Crawlability, Inc.
Copyright © 2003-2011 Automation Anywhere, Inc. All rights reserved