A While statement is a loop statement that keeps repeating while a given condition is True.
whilestmt ::= While expression Do stmtblock EndWhile ;
The expression is any expression that yields a Logical value. If the expression yields any other type then the compiler will reject it.
The stmtblock is a standard list of statements with an optional OnError section.
The statement block will be executed repeatedly as long as the expression, which is re-evaluated each time around the loop, remains True. If the expression yields a False result the loop will stop. If the expression yields a Null result a runtime error is generated. This error will be caught outside the loop, rather than by the OnError statements for the loops own statement block.
n := 100; While n >= 50 Do Circle(n); n -= 10; EndWhile;
Within the statement block, including within the error handler section, you may have a WBreak statement. This has the form :-
wbreakstmt ::= WBreak ;
The WBreak will normally be nested within some form of conditional statement. If a WBreak occurs within a set of nested While loop it will only break out of the innermost.