Loop Expression Action Icon

Loop Expression

Declaration

<AMLOOPEXPRESSION EXPRESSION="text [valid BASIC expression]" CONDITION="text [options]">
  (block of steps to loop)

See Also

Loop | End Loop | Loop Files | Loop Windows | Loop Processes | Loop Expression | Loop Dataset | Loop List | Loop List Control | Loop Processes | Loop Tree Control | Loop Windows | Break

Description

Loops while or until the expression specified is true. With each successive loop, 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 Properties

Property

Type

Required

Default

Markup

Description

Condition

Text (options)

Yes

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 (default).

  • Loop until the expression is true.

Expression

Text

Yes

(Empty)

EXPRESSION="thenumber=55"

Specifies a valid BASIC expression that should be evaluated on each loop.

 

Description Properties

The Description tab allows you to customize the text description of any step as it appears in the Task Builder's Steps Pane.

More on setting custom step description

Error Causes Properties

The Error Causes tab properties lets you instruct a task step to react only to specific errors or ignore certain errors that should cause it to fail.

More on Error Causes properties

On Error Properties

The On Error tab properties lets you determine what the task should do if a particular step encounters an error as defined in the Error Causes properties.

More about On Error properties

Additional Notes

Expressions, Variables & Functions

A percent sign is used as a special character in AutoMate to indicate the beginning and end of an expression. This allows variables, functions and other expressions to be entered in any text parameter of a task's properties. For example: %1+1% inside a task will resolve to 2 at runtime. A more elaborate example is %FileDateTime(myFile)% which results to the date/time of myFile. To help construct expressions, you can open Expression Builder by clicking the Insert Expression (%) button or by pressing F2.

More on expressions

More on variables

More on functions

More on extended functions
More on the expression builder

Example

NOTE: The code below can be copied and pasted directly into the Steps pane of the Task Builder.

 

Sample 1 - Loop until expression is true.

 

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

 

<AMVARIABLE NAME="mycounter">1</AMVARIABLE>

<AMLOOP TYPE="EXPRESSION" EXPRESSION="mycounter=1 or mycounter=2">

     <AMMESSAGEBOX>%mycounter%</AMMESSAGEBOX>

     <AMINCREMENTVARIABLE RESULTVARIABLE="mycounter" />

</AMLOOP>

 

↑ Top of Page