HP Pascal/iX Reference Manual (31502-90022)

4-: 13
Example
PROGRAM show_in(output);
VAR
ch : char;
good : SET OF char;
member : Boolean;
BEGIN
ch := 'y';
good := ['y','Y','n','N'];
IF ch IN good THEN
member := true
ELSE
member := false;
writeln(member);
END.
Output:
TRUE
Pointer Relational Operators
The
pointer relational
operators = and <> can be used to compare two
pointers
for equality or inequality, respectively. Two pointers are
equal only if they point to exactly the same object or both contain the
value NIL. Only two pointers of identical type or the constant NIL can be
compared.
Example
PROGRAM show_pointer_relational;
VAR
a, b: boolean;
p, q: ^boolean;
x: ^char;
BEGIN
.
.
IF (p = q) AND (p <> NIL) THEN p^:= a = b; { pointer }
b := x <> q; { is an error - x and q are not compatible }
END.
NOTE No assumptions should be made about the integer values of pointers
and their integer value relations. Such values and relations are
undefined.
String Relational Operators
The
string relational
operators =, <>, <, <=, >, or >= may be used to
compare operands of type
string
,
PAC
,
char,
or
string literals
. The
system performs the comparison character by character using the order
defined by the ASCII collating sequence. Note that it is not possible to
compare a string variable with a PAC or char variable. In general, these
guidelines are as follows:
* If one operand is a string expression, the other operand may be a
string expression or string literal. If the operands are not the
same length and the two are equal up to the length of the shorter,
the shorter operand is less. For example, if the current value of
S1 is abc and the current value of S2 is ab, then S1 > S2 is
true
.
* If one operand is a PAC expression, the other may be a PAC or
string literal of any length. The shorter is blank-filled prior
to comparison.