Action Descriptions: Loop

A Loop action is the same as a Decision Branch action, except that once the action has completed it will re-evaluate the condition, and execute as long as the branch condition remains true. Basically, a loop is a repeating decision branch. To access this action in the Event editor, choose the Basics button from the Actions list.

Loop Procedures

Loop Example

One possible way to use a Loop action would be in an amortization application. You could compare the field that contains the principal amount with zero. Then, when the principal is paid off, the application could navigate users to a "congratulations" form, where they could be offered a reverse mortgage.

To build this example with a Loop, you could use the default rule "When all are false," with a condition test for the field that contains the principal amount, comparing it to a global variable containing a constant value of zero. As long as the principal does not equal zero, the loop will run. While the loop executes a payment function that incrementally reduces the principal amount, the Loop action would continually make its comparison. When the value for the principal field is equal to zero, the branch evaluates to false. The execution thread for the event moves on to the next action, Display Form, to send the user to a different form.

Loop Properties

Property Description
Name This optional property can help with identification when you use multiple decision branches.
Expression Type (Rule) This is the statement that must evaluate to true for the event to continue. For example, the "all" in the statement "When all are true" refers to all of the condition tests added to the expression. Click the Add Rule button to select an expression type. Options include:
  • When all are true
  • When at least one is true
  • When all are false
  • When at least one is false
Condition Tests To evaluate a condition, you build a test that compares two operands. The operands can be fields on a host screen, constants you define, values of controls on a form — basically, any of the data elements available to your application at that time.

Either operand can be compared with a constant that you define, by right-clicking the selected data element and choosing Compare with Constant. When using constants, do not use the following characters: +, -, \, /, (, ), or '. (The expression evaluator handles these characters in a particular way; therefore, they cannot be used as part of the constant values in a test condition of a loop step.)

Operator The operator used to compare the operands. Select from the following. (Default: equals.)
Operator Name
Operator
equals ==
Not equals !=
Less than <
Greater than >
Greater than or equals >=
Less than or equals <=
like like
Note If you are using the like operator, include a wildcard character (*) in the operand to which you are comparing a control value. For example, if your control values are abc, abd, and abe, you would get the following results:
If the
control value is
   The expression
evaluates to
like 'b' false
like 'ab' false
like 'ab*' true
like '*b*' true
Type The data type of the selected operands. Select either String or Number. (Default: String.)

If the type is String, for example, the statement "10.0" > "10" is true. However, it will evaluate as false if the type is set to Number.

Related Topics
Bullet Adding Actions to Events
Bullet Adding Loops to Events
Bullet Adding Decision Branches to Events
Bullet Action Descriptions: Decision Branch
  Attachmate