Loop Constructs

ViviFire's loop constructs let you execute a set 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 executes a block 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 executes while the condition is true or until it becomes true. See Do…Loop Statement for more information.

For loops

The construct For executes a block of statements a specified 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 executes a block of statements one time for each element in a collection. It is best used where you can safely ignore qualities, for example, the dimensions and configuration of the collection. See For Each Statement for more information.

Begin…When clauses

For most loop constructs, ViviFire lets you write statements that are in the loop but execute externally. The line When DONE executes only if the body of the loop executed fully and completed as usual. The line When NONE executes only if the body of the loop did not start. See Begin…When Statements for more information.

See also