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.

General Parameters

Property

Type

Required

Default

Markup

Description

Condition

Text (options)

Yes

While

  1. CONDITION="while"

  2. 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 (default) - Example: Execute the code while x equals five.

  • Loop until the expression is true - Example: Execute the code until x equals five.

Expression

Text

Yes

(Empty)

EXPRESSION="thenumber=55"

A valid BASIC expression that should be evaluated on each loop.

Description tab - A custom description can be provided on the Description tab to convey additional information or share special notes about a task step.

Error Causes tab - Specify how this step should behave upon the occurrence of an error. (Refer to Task Builder > Error Causes Tab for details.)

On Error tab - Specify what AWE should do if this step encounters an error as defined on the Error Causes tab. (Refer to Task Builder > On Error Tab for details.)

Example

The sample AML code below can be copied and pasted directly into the Steps panel of the Task Builder.

Sample 1:Loop until expression is true. This task will loop until the expression MyCounter=5 evaluates to TRUE. Within the loop, a dialog box will appear showing the current value of the variable which increments by one upon each successive loop.

<AMVARIABLE NAME="mycounter">1</AMVARIABLE>
<AMLOOP TYPE="EXPRESSION" EXPRESSION="mycounter=5" CONDITION="until">
<AMMESSAGEBOX>%mycounter%</AMMESSAGEBOX>
<AMINCREMENTVARIABLE RESULTVARIABLE="mycounter" />
</AMLOOP>

Sample 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 box will appear showing the current value of the variable.

<AMVARIABLE NAME="mycounter">1</AMVARIABLE>
<AMLOOP TYPE="EXPRESSION" EXPRESSION="mycounter=1 or mycounter=2">
<AMMESSAGEBOX>%mycounter%</AMMESSAGEBOX>
<AMINCREMENTVARIABLE RESULTVARIABLE="mycounter" />
</AMLOOP>