Loop

Loops through the range of numbers specified. With each successive loop, a block of steps are executed. An index variable can optionally update the current loop count. The loop ends after the counter has reached the number specified or when a Break is encountered. This action is often distinguished by an explicit loop counter or loop variable allowing the body of the for loop (the steps that are being repeatedly executed) to know about the sequencing of each iteration. Frequently used in to loop a series of steps a number of times.

Declaration

<AMLOOP FROM="number" TO="number" STEP="number" RESULTVARIABLE="text">

See Also: End Loop, Loop Files, Loop Windows, Loop Expression, Loop Dataset, Loop List, Loop List Control, Loop Tree Control

To set Loop properties

  1. In the Available Actions pane, open the Loop folder and double-click the Loop action or drag it into the Steps pane.

  2. Do one of the following:

  3. Click the Advanced tab.

  4. If you want to increment the loop count by something other than one, select Increment by step and enter the increment value. For example if you enter 2 and you have a starting index of 1 and an ending index of 6, there will be three loops, and the index counts will be 2, 4, and 6.

  5. To populate a variable with the loop count, select Populate variable with index count and then select the variable from the drop-down list. (The variable must be created in an earlier step using the Create Variable action.)

  6. To set the Description tab properties, refer to Description Tab Options.

  7. To set the Error Causes and On Error tab properties, refer to Step Error Handling.

  8. When finished, click OK to save settings and close the properties dialog box.

To auto-indent after all steps are added

  1. In the Steps pane, hold down SHIFT and click the first and last steps in the block so that the complete block of steps is selected.

  2. Click Format .

General Tab

Property

Type

Required

Default

Markup

Description

Total Loops

Number

Yes if FROM and TO parameters are not specified

1

TOTALLOOPS="10"

The number of loops to be performed. If the Starting Index and Ending Index parameters are specified, this parameter is ignored.

NOTE: Specifying TOTALLOOPS="10" is the same as specifying FROM="1" and TO="10"

Starting Index

Number

Yes if TOTAL LOOPS parameter is not specified

1

FROM="3"

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. If the Total Loops parameter is specified, this parameter is ignored.

Ending Index

Number

Yes if TOTAL LOOPS parameter is not specified

1

TO="10"

The number to count up to when determining the number of times to loop. If the Total Loops parameter is specified, this parameter is ignored.

Advanced Tab

Property

Type

Required

Default

Markup

Description

Increment by step

Number

No

1

STEP="2"

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

Populate variable with index count

Text

No

1

RESULTVARIABLE="theVar"

The name of the variable to populate with the current counter value. This number starts at the value entered in the Starting Index parameter and is incremented by the value entered in the Increment by step parameter until it reaches the value entered in the Ending Index parameter.

See Also

About Actions

Adding Task Steps