A while statement is used to execute a statement as long as a certain condition holds. In difference with the repeat loop, this may imply that the statement is never executed.
The prototype syntax of the While..do statement is
_________________________________________________________________________________________________________
While statements
___________________________________________________________________
This will execute Statement as long as Expression evaluates toTrue. Since Expression is evaluated before the execution of Statement, it is possible that Statement isn’t executed at all. Statement can be a compound statement.
Be aware of the fact that the boolean expression Expression will be short-cut evaluated by default, meaning that the evaluation will be stopped at the point where the outcome is known with certainty.
The following are valid while statements:
They correspond to the example loops for the repeat statements.
If the statement is a compound statement, then the Break and Continue reserved words can be used to jump to the end or just after the end of the While statement. Note that Break and Continue are not reserved words and therefore can be overloaded.