Contents | Prev | Next
9.9 Repeat statement
Description
Repeat statements perform an action in a conditional loop until the loop condition
is true, and include the following:
- A statement-sequence that specifies the action performed in the loop. If a statement in
the statement-sequence transfers program execution to a statement outside of the
repeat statement then execution of the repeat statement is terminated
when program execution is transfered.
- The loop condition, which is specified by an
expression of
boolean type. After each iteration of the loop the
loop condition is evaluated and if it's value is false the
loop continues, but if it's value is true the loop
terminates.
NOTE: The loop condition is evaluated after the statement-sequence is executed so
the statement-sequence is executed at least once. Usually the statement-sequence will perform
some action that will eventually cause the loop condition to be
true and terminate the loop.
Example
For example, below is a very simple program which illustrates the use of the "repeat" statement.
program ten(output);
var
count : 1..11;
begin
count := 1;
repeat
writeln(count);
count := count + 1
until count > 10
end.
Syntax
(NOTE: for clarity some parts of the syntax are omitted, see
Irie Pascal Grammar for the full syntax):
repeat-statement = 'repeat' statement-sequence 'until' boolean-expression
statement-sequence = statement { ';' statement }
Contents | Prev | Next