Loop - Expression
Declaration
<AMLOOP ACTIVITY="expression" CONDITION="until" EXPRESSION="text" />
Description
Loops while or until the specified expression is true. With each successive iteration, the expression is re-evaluated. The loop ends after the condition is met or when a Break is encountered.
Practical usage
Used to continue executing a block of steps while or until a condition is met.
Parameters
General
Property | Type | Required | Default | Markup | Description |
---|---|---|---|---|---|
Expression | Text (options) | Yes | While |
| Specifies whether the loop should continue while the expression is true or until it is true. The available options are:
|
Expression | Text | Yes | (Empty) | EXPRESSION="thenumber=55" | A valid BASIC expression that should be evaluated on each loop. |
Example
- Copy and paste the sample AML code below directly into the Task Builder Steps Panel.
- To successfully run the sample code, update parameters containing user credentials, files, file paths, or other information specific to the task to match your environment.
Example 1
Loop until expression is true. This task will loop until the expression MyCounter=5 evaluates to TRUE. Within the loop, a dialog will appear showing the current value of the variable which increments by one upon each successive loop.
<AMVARIABLE NAME="mycounter" VALUE="1"></AMVARIABLE>
<AMLOOP ACTIVITY="expression" CONDITION="until" EXPRESSION="mycounter=5" />
<AMSHOWDIALOG>%mycounter%</AMSHOWDIALOG>
<AMVARIABLE ACTIVITY="increment" RESULTVARIABLE="mycounter" />
<AMLOOP ACTIVITY="end" />
Example 2
Loop while the expression is true. This task will loop until the 'MyCounter' variable does not equal to 1 or 2. Within the loop, a dialog will appear showing the current value of the variable.
<AMVARIABLE NAME="mycounter" VALUE="0" />
<AMLOOP ACTIVITY="expression" CONDITION="until" EXPRESSION="mycounter=1 or mycounter=2" />
<AMSHOWDIALOG>%mycounter%</AMSHOWDIALOG>
<AMVARIABLE ACTIVITY="increment" RESULTVARIABLE="mycounter" />
<AMLOOP ACTIVITY="end" />