Loop Constructs

ViviFire's loop constructs let you run a sequence of statements many times. You can execute statements while a condition is true, until a condition becomes false, a given number of times, or for each element in a collection.

While loops

The construct While runs a sequence of statements while the condition you give at the start is true. See While Statement for more information.

Do loops

The construct Do…Loop is almost the same as While, but can adapt better. You can do the test at the start or at the end. You specify if the loop runs while the condition is true or until it becomes true. See Do…Loop Statement for more information.

For loops

The construct For runs a sequence of statements a given number of times. It goes through a range of values and changes a variable, known as the counter, to a different value each time through the loop. You can optionally specify the interval of the step, which has a default of one (1). See For Statement for more information.

For Each loops

The construct For Each runs a sequence of statements one time for each element in a collection. It is best used where you can safely ignore the dimensions and configuration of the collection, for example. See For Each Statement for more information.

Exit When clauses

For most loop constructs, ViviFire lets you write statements that are a part of the loop but have an auxiliary function. The code after When DONE runs only if the body of the loop ran fully and completed as usual. The code after When NONE runs only if the body of the loop did not start. See Exit When Clause for more information.

See also