HP Pascal/iX Reference Manual (31502-90022)

6: 11
Example
{ VAR color: (red, green, blue, yellow); }
FOR color := red TO blue DO
writeln ('Color is ', color);
.
.
FOR i := 10 DOWNTO 0 DO
writeln (i);
writeln ('Blast Off');
.
.
FOR i := (a[j] * 15) TO (f(x) DIV 40) DO
IF odd(i) THEN
x[i] := cos(i)
ELSE
x[i] := sin(i);
REPEAT .. UNTIL
A REPEAT statement executes a statement or group of statements repeatedly
until a Boolean expression is
true
. It consists of the reserved word
REPEAT, one or more statements, the reserved word UNTIL, and a Boolean
expression (the condition). The statements between REPEAT and UNTIL need
not be bracketed with BEGIN..END.
When the system executes a REPEAT statement, the following occurs:
1. It executes the statement sequence, and then evaluates the Boolean
expression.
2. If it is false, it executes the statement sequence and evaluates
the Boolean expression again.
3. If it is true, control passes to the statement after the
REPEAT...UNTIL statement.
The statement:
REPEAT
statement;
UNTIL condition
is equivalent to the following:
1: statement;
IF NOT condition THEN GOTO 1;
Usually the statement sequence modifies data at some point so that the
condition becomes
true
. Otherwise, the REPEAT statement loops forever.
Syntax
Repeat_statement: