Loop List Action

Description

Loops through items in a list (comma, carriage return, or other delimited text). With each successive loop a block of steps is executed and the current index variable is updated with the next item in the list. The loop ends when at the end of the list or when a Break is encountered.

Declaration

<AMLOOPLIST LIST="text [list]" RESULTVARIABLE="text [varname]" DELIMITER="text [options]" SORT="text [options]">
  (block of steps to loop)
</AMLOOP>

Examples

<AMVARIABLE NAME="thenames">Dustin,Scott,Jeff,Kirsten</AMVARIABLE>
<AMVARIABLE NAME="currentitem"></AMVARIABLE>
<AMLOOPLIST LIST="%thenames%" RESULTVARIABLE="currentitem">
<AMMESSAGEBOX>%currentitem%</AMMESSAGEBOX>
</AMLOOP>

 

<!--- This Workflow 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 to it--->
<AMVARIABLE NAME="filecontents"></AMVARIABLE>
<AMVARIABLE NAME="currentitem"></AMVARIABLE>
<AMFILEREAD FILE="c:\thelistfile.txt" RESULTVARIABLE="filecontents">
<AMLOOPLIST LIST="%filecontents%" RESULTVARIABLE="currentitem" DELIMITER="new_line">
<AMMESSAGEBOX>%currentitem%</AMMESSAGEBOX>
</AMLOOP>

General Tab Parameters

List: Specifies a list of data to Loop through. The List can be delimited by a variety of characters.

Text, Required
MARKUP: LIST="Dustin,Scott,Jeff,Kirsten"

Populate variable with list item: Specifies 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.

Number, Optional Default - 0
MARKUP: RESULTVARIABLE="VARNAME"

Delimiter: Specifies the character that delimits the items in the list. (Do not add a space between items, unless the delimiter is a space.)

  • comma: The delimiter is a comma (e.g., item1,item2,item3).

  • new_line: The delimiter is a new line.

  • semi_colon: The delimiter is a semi colon (e.g., item1;item2;item3).

  • space: The delimiter is a space (e.g., item1 item2 item3).

  • tabulation: The delimiter is a tab character.

  • (custom): The delimiter is another character as specified (simply use the character).

Text, Optional - Default - Comma
MARKUP: DELIMITER="new_line"

Advanced Tab Parameters

Output list: Specifies whether a sort order should be applied to the values before the loop begins. For example, selecting "ascending" would return the list items in alphabetical order. The available options are:

  • none: The results are left in their natural order and not sorted.

  • ascending: The results sorted in ascending alphabetical order.

  • descending: The results sorted in descending alphabetical order.

Text [options], Optional (default "none")
MARKUP: SORT="ascending"

See Also

Loop, Loop Files, Loop Windows, Loop Processes, Loop Expression, Loop Dataset, Break, End Loop