Loop Action Icon

Loop Action

Declaration

<AMLOOP FROM="number" TO="number" INDEX="text" STEP="number">
  (block of steps to loop)
</AMLOOP>

See Also

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

Description

Loops through the range of numbers specified. The variable specified in the Index parameter is updated with the current loop count. With each successive loop a block of steps is executed and the loop counter is incremented by the number specified in the Step parameter. The loop ends after the counter has reached the number specified in the stop parameter or when a Break is encountered.

Practical Usage

To loop a block of steps through a range of numbers.

Parameters

General Tab

From
Number, Required
MARKUP: FROM="10"

Specifies the number to start counting from when determining the number of times to loop. This value will be reflected in the index value returned as well.

To
Number, Required
MARKUP: TO="20"

Specifies the number to count up to when determining the number of times to loop.

Step
Number, Optional - Default 1
MARKUP: STEP="2"

The number by which the index is incremented by when looping through the FROM= and TO= parameters. For example, if FROM=1 and TO=10 and STEP=2 then the action would loop 5 times, if STEP=1 then it would loop 10 times and so on.

Index
Text, Optional
MARKUP: INDEX="VARNAME"

Species the name of a variable to populate with the current counter value. This number starts at FROM= and is incremented by STEP= each loop, until TO= is reached.

Notes

Standard Error Handling Options
This action also includes the standard "Error Causes" and "On Error" failure handling options/tabs

More on Error Handling Options

Variables and Expressions
All text fields allow the use of expressions by surrounding the expression in percentage signs (example: %MYVARIABLE%, %Left('Text',2)%). To help construct these expressions, a popup expression builder is available in all these fields by pressing F2.
More on variables...
More on expressions...
More on the expression builder...

Examples

<AMVARIABLE NAME="MYCOUNTER">
<AMLOOP FROM="1" TO="10" INDEX="MYCOUNTER">
  <AMMESSAGEBOX MESSAGETEXT="%MYCOUNTER%">
</AMLOOP>