LOTUSSCRIPT LANGUAGE


Do statement
Example

Executes a block of statements repeatedly while a given condition is true, or until it becomes true.

Syntax 1

Do [ While | Until condition ]

[ statements ]

Loop

Syntax 2

Do

[ statements ]

Loop [ While | Until condition ]

Elements

condition


Usage

In Syntax 1, condition is tested before entry into the loop, and before each subsequent repetition. The loop repeats as long as condition evaluates to TRUE (if you specify While), or until condition evaluates to TRUE (if you specify Until).

In Syntax 2, condition is tested after the body of the loop executes once, and after each subsequent repetition. The loop repeats as long as condition evaluates to TRUE (if you specify While), or until condition evaluates to TRUE (if you specify Until).

Terminating the loop

You can exit the loop with an Exit Do statement or a GoTo statement. Exit Do transfers control to the statement that follows the Do...Loop block; GoTo transfers control to the statement at the specified label.

If you do not specify a While or Until condition, the loop will run forever or until an Exit Do or a GoTo statement is executed within the loop. For example, this loop executes forever:

Do  
  ' ...
Loop

Language cross-reference

@DoWhile function in formula language

@While function in formula language

Example
See Also