Loop Constructs

ViviFire's loop constructs allow you to repeatedly execute a set of statements. You can repeat statements while a condition is true, until a condition becomes false, a specified number of times, or once per element in a collection.

While loops

The While construct executes a block of statements as long as the condition you give at the start is true. See While Statement for more information.

Do loops

The Do...Loop construct is similar to While, but with greater flexibility. You can test the condition either at the start or the end. You specify whether the loop executes while the condition is true or until it becomes true. See Do...Loop Statement for more information.

For loops

The For construct executes a block of statements a fixed number of iterations. It steps through a range of values assigning a variable, called the counter, a different value for each iteration. You can optionally specify the step size, which has a default of 1. See For Statement for more information.

For Each loops

The For Each construct executes a block of statements once for each element in a collection. It is best used where you can safely disregard factors such as the size and order of the collection. See For Each Statement for more information.

Begin...When clauses

For most loop constructs, ViviFire supports statements that appear inside the loop but are executed outside of it. The When %DONE clause is executed only if the body of the loop in which it appears executed fully and exited normally. The When %NONE clause is executed only if the body of the loop was never entered. See Begin...When Statements for more information.

See also