While statements perform an action in a conditional loop as long as the loop
condition is true, and include the following:
NOTE: The loop condition is evaluated before the statement in the
while statement is executed so this statement may never be executed. Usually the
statement in the while statement will perform some action that will eventually
cause the loop condition to be false and terminate the
execution of the loop.
- The loop condition, which is specified by an
boolean type. Before each iteration of the loop the
loop condition is evaluated and if its value is true the
loop continues, but if its value is false the loop
- A statement that specifies the action performed in the loop. This statement can be
a compound statement, containing a statement-sequence.
If this statement transfers program execution to a statement outside
of the while statement then execution of the while statement is
terminated when program execution is transfered.
For example below is a very simple program which illustrates the use of the "while" statement.
count : 1..11;
count := 1;
while count <= 10 do
count := count + 1;
(NOTE: for clarity some parts of the syntax are omitted, see
Irie Pascal Grammar for the full syntax):
while-statement = 'while' boolean-expression 'do' statement