The while instruction repeats a block of instructions while its Boolean condition is true. The condition is tested before each iteration, so the block is never executed if the condition is initially false.
Before the block to be repeated, place a while statement containing the boolean expression that determines if the loop will be performed.
while SomeBooleanExpressionIsTrue
// do something
endwhile
The whole point of the while loop is to re-evaluate a condition prior to every loop (which means that if the condition is false from the beginning, the loop will never be entered).
Recall that the elements of a for loop could not be modified in the loop, nor could they vary, but in the case of a while loop the following is allowed and often used.
// increase the date until we reach a Saturday
while WeekDayOf(nDate) <> 6
inc(nDate)
endwhile
To interrupt the flow of a while loop, use the break or continue commands.
See also: for loops.
Topic 105132, last updated on 09-Oct-2026