Loop - List
Declaration
<AMLOOP ACTIVITY="list" LIST="text" DELIMITER="text (options)theFile">
Description: Loops through delimited items in a list. The current index variable is updated with the next item in the list. With each loop the current item in the list is returned. The loop process ends when the last delimited item is reached or when a Break is encountered.
Practical Usage
Normally used in conjunction with the Read from file activity to perform operations on delimited text. Note that in certain situations, a Loop file contents activity may be preferable due to the fact that it combines the functionality of both the 'Read from file' and 'Loop list' activities into a single activity.
General Parameters
Property |
Type |
Required |
Default |
Markup |
Description |
---|---|---|---|---|---|
List |
Text |
Yes |
(Empty) |
LIST="Item1,Item2,Item3" |
The list of data to Loop through. The List can be delimited by a variety of characters. |
Populate variable with list item |
Text |
Yes |
(Empty) |
RESULTVARIABLE="varname" |
The name of the variable to populate with the current list item. With each successive loop, this variable will be populated with the next item in the list. |
Delimiter |
Text (options) |
No |
Comma |
|
The character used to delimit the items in the list. The available options are:
|
Advanced Parameters
Property |
Type |
Required |
Default |
Markup |
Description |
---|---|---|---|---|---|
Output list sort order |
Text (options) |
No |
None |
|
Specifies the sort order that should be applied towards the list before the loop begins. The available options are:
|
Description tab - A custom description can be provided on the Description tab to convey additional information or share special notes about a task step.
Error Causes tab - Specify how this step should behave upon the occurrence of an error. (Refer to Task Builder > Error Causes Tab for details.)
On Error tab - Specify what AWE should do if this step encounters an error as defined on the Error Causes tab. (Refer to Task Builder > On Error Tab for details.)
Examples
The sample AML code below can be copied and pasted directly into the Steps panel of the Task Builder.
Sample 1 - This task loops through comma delimited text and displays each delimited item in a message box during each loop process.
<AMVARIABLE NAME="thenames">Dustin,Scott,Jeff,Kirsten</AMVARIABLE> <AMVARIABLE NAME="currentitem"></AMVARIABLE> <AMLOOP TYPE="LIST" LIST="%thenames%" RESULTVARIABLE="currentitem"> <AMMESSAGEBOX>%currentitem%</AMMESSAGEBOX> </AMLOOP>
Sample 2 - This task shows reading in a file with multiple lines. Each line of the file is treated as a list item. To use it, you must create a text file called c:\thelistfile.txt and add a few lines of text to it.
<AMVARIABLE NAME="filecontents"></AMVARIABLE> <AMVARIABLE NAME="currentitem"></AMVARIABLE> <AMFILEREAD FILE="c:\thelistfile.txt" RESULTVARIABLE="filecontents" /> <AMLOOP TYPE="LIST" LIST="%filecontents%" RESULTVARIABLE="currentitem" DELIMITER="new_line"> <AMMESSAGEBOX>%currentitem%</AMMESSAGEBOX> </AMLOOP>