HP Pascal/iX Reference Manual (31502-90022)

9- 31
Example
Input Result
chr(x) depends on the value of x
chr(63) '?'
chr(82) 'R'
chr(13) (carriage return)
ord
Usage
ord
(x)
Argument
x
An ordinal expression.
Description
The function ord
(x)
returns the integer representing the ordinal
associated with the value of
x
. If
x
is an integer,
x
itself is
returned. If
x
is type char, the result is an integer value between 0
and 255 determined by the ASCII order sequence. If
x
is any other
ordinal type (such as a predefined or user-defined enumerated type), then
the result is the ordinal number determined by mapping the values of the
type onto consecutive non-negative integers star ting at zero. For
example, since the standard type Boolean is predefined as:
TYPE Boolean = (false,true)
The call ord (false) returns 0, and the call ord (true) returns 1.
For any character ch, the following is true:
chr (ord (ch)) = ch
It is an error if the result is greater than
maxint
or less than
minint
.
Example
Input Result
ord(ord_exp) depends on the value of ord_exp
ord('a') 97
ord('A') 65
ord(-1) -1
ord(yellow) 2 {TYPE color=(red,blue,yellow)}
ord(red) 0
NOTE Taking the ORD of short pointer type expressions is permitted at
the Standard_Level EXT_MODCAL.
pred
Usage
pred
(n)
Argument
x
Any ordinal expression.