While statement


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.


For example below is a very simple program which illustrates the use of the "while" statement.

   program ten(output);
      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