6.8.3.10 While Statement

Syntax

while expression

statements

endwhile

Description

The while statement repeatedly executes the statements while the expression is true.

If the expression is true, the statements following the while are executed. At the endwhile, control goes back to the while statement, and the expression is evaluated again. If it is true, the process repeats. When the expression is false, control goes to the statement following the endwhile.

While statements can be nested to any level. A while statement can appear as a statement within a while statement.

The value of the while statement is the value of the last statement evaluated within the while, or an empty string if no statements were evaluated within the while.

Example

set index to 1

while index <= 5

if array[index] > 100

return "array[" :: index :: "] too big"

endif

set index to index + 1

endwhile