HP Pascal/iX Reference Manual (31502-90022)

6: 7
END;
END;
. . . .
FUNCTION octal_digit (d:digit): Boolean; { TYPE digit = 0..9 }
BEGIN
CASE d OF
0..7: octal_digit := true;
8..9: octal_digit := false;
END;
END;
. . . .
FUNCTION op { TYPE operators=(plus,minus,times,divide) }
(operator: operators;
operand1,
operand2: real)
: real;
BEGIN
CASE operator OF
plus: op := operand1 + operand2;
minus: op := operand1 - operand2;
times: op := operand1 * operand2;
divide: op := operand1 / operand2;
END;
END;
IF .. THEN
IF .. THEN .. ELSE
An IF statement specifies a statement the system executes, if a
particular condition is
true
. If the condition is
false,
then the system
doesn't execute that statement, and optionally, it executes another
statement starting after the ELSE.
The IF statement consists of the reserved word IF, a Boolean expression,
the reserved word THEN, a statement, and, optionally, the reserved word
ELSE and another statement. The statements after THEN or ELSE may be any
HP Pascal statements, including other IF statements or compound
statements. No semicolon separates the first statement and the reserved
word ELSE.
When an IF statement is executed, the Boolean expression is evaluated to
either
true
or
false
, and one of the following three actions is
performed:
* If the value is true, the statement following THEN is executed.
* If the value is false and ELSE is specified, the statement
following the ELSE is executed.
* If the value is false and no ELSE is specified, execution
continues with the statement following the IF statement.
The following IF statements are equivalent:
IF a = b THEN IF a = b THEN
IF c = d THEN BEGIN
a := c IF c = d THEN
ELSE a := c
a := e; ELSE
a := e;
END;