Loop - Expression

Declaration

<AMLOOP ACTIVITY="expression" CONDITION="until" EXPRESSION="text" />

Related Topics   

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

 
PropertyTypeRequiredDefaultMarkupDescription
ExpressionText (options)YesWhile
  • CONDITION="while"
  • CONDITION="until"

Specifies whether the loop should continue while the expression is true or until it is true. The available options are:

  • Loop while the expression is true - Example: Execute the code while x equals five.
  • Loop until the expression is true - Example: Execute the code until x equals five.
ExpressionTextYes(Empty)EXPRESSION="thenumber=55"A valid BASIC expression that should be evaluated on each loop.

Description

Error Causes

On Error

Example

NOTE:
  • 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.

Copy
<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.

Copy
<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" />