ORD - ordinal value of a scalar type.

Usage:

i := ord(s);

Where:

s
is an expression with a scalar type (including enumerated types, boolean, char, and integer, plus subranges).
i
is an integer.

Description:

The "ord" function is a way to convert a scalar type to a corresponding integer.

If the argument of "ord" is an integer, the return value is simply the value of the argument.

If the argument is a character, the return value is equal to the ASCII representation of the character.

If the argument is an enumerated value, the return value is based on the position of the value in the list where the enumerated type was created. For example, suppose you have

type
    days = (sun,mon,tue,wed,thu,fri,sat);

Each enumerated value has an associated "ord" value, beginning at 0 for "sun". Thus "ord(mon)" is 1, "ord(tue)" is 2, and so on. The assignment of values to the enumerated type values can also be dictated explicitly in the source code, as described in the Pascal manual.

See Also:

expl pascal lib chr

Copyright © 1996, Thinkage Ltd.