HP Pascal/iX Reference Manual (31502-90022)

6: 5
Example
PROGRAM show_assign(input,output);
VAR
aaa: integer;
FUNCTION show_assign: integer;
TYPE
rec = RECORD
f: integer;
g: real;
END;
index = 1..3;
table = ARRAY [index] of integer;
CONST
ct = table [10, 20, 30];
cr = rec [f:2, g:3.0];
VAR
s: integer;
a: table;
i: index;
r: rec;
p1,
p: ^integer;
strg: string[10];
BEGIN { show_assign }
s:= 5; i:= 3;
a:= ct;
a [i] := s + 5;
r:= cr;
r.f:= 5;
new (p1);
p:= p1;
p^:= r.f - a [i];
strg:= 'Hi!';
show_assign := p^;
END; {show_assign}
BEGIN
aaa:= show_assign;
END.
CASE
The CASE statement selects a certain action based upon the value of an
ordinal expression. It consists of the reserved word CASE, a selector,
the reserved word OF, a list of case constants and statements, and the
reserved word END. Optionally, the reserved word OTHERWISE and a list of
statements may appear after the last constant and its statement.
The
selector
must be an ordinal expression in that it must return an
ordinal value. A
case constant
may be a literal, a constant identifier,
or a constant expression that is type compatible with the selector.
Subranges may also appear as case constants.
A case constant cannot appear more than once in a list of case constants.
Subranges used as case constants may not overlap other constants or
subranges. However, several constants may be associated with a
particular statement by listing them separated by commas.