Loop - Break

Declaration

<AMBREAK />

Related Topics   

Description

Breaks out of a Loop or If statement.

Practical usage

Can be used inside a Loop activity to break out of the loop if a particular condition takes place.

Parameters

There are no parameters for this activity.

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.

Description

This sample task loops 6 times and examines the current value to see if it is greater than or equal to 3 during each iteration. If the value is greater than or equal to 3, the task breaks out of the loop using the Break action.

Copy
<AMVARIABLE NAME="indexvar" VALUE="" />
<AMLOOP TOTALLOOPS="6" RESULTVARIABLE="indexvar"><AMSHOWDIALOG>%indexvar%</AMSHOWDIALOG><AMIF EXPRESSION="%indexvar% &gt;= 3"><AMBREAK /></AMIF></AMLOOP>
<AMSHOWDIALOG>%indexvar%</AMSHOWDIALOG>
<AMIF EXPRESSION="%indexvar% &gt;= 3" USECOMPLEXUI="YES" />
<AMBREAK />
<AMIF ACTIVITY="end" />
<AMLOOP ACTIVITY="end" />