Represents a set of named ordered values via a named type.
DEFINE ORDINAL ordinal_type_name {member_name [VALUE(integer)] [,...]} [{PRECISION | PREC}] (integer) [SIGNED | UNSIGNED]
The value assigned or assumed for the VALUE attribute must be a signed or unsigned integer, and may be specified as an XN constant. It must strictly increase.
define ordinal Subjects (Mathematics, /* 0, starting value is zero when VALUE not specified */ Literature, /* 1 */ Science, /* 2 */ History); /* 3 */ define ordinal Math (Algebra VALUE(101), /* 101*/ Geometry, /* 102 */ Calculus VALUE(301)); /* 301 */
define ordinal Subjects (Arithmetic, /* 0, starting value is zero when VALUE not specified */ Literature, /* 1 */ Science, /* 2 */ History); /* 3 */ dcl x ordinal Subjects; do x = first(:Subjects:) upthru last(:Subjects:); put skip list (ordinalname(x)); end;
Prints:
MATHEMATICS LITERATURE SCIENCE HISTORY
Declare subject ORDINAL Subjects; Declare course TYPE Math; /* ORDINAL & TYPE keywords are interchangeable */ subject = Mathematics; course = Calculus; if subject = Mathematics then if course = Calculus then put skip list ('At the upper Limit!'); subject = Algebra; /* illegal assignment, mismatched ordinal types */ if subject = course then /* illegal comparison, mismatched ordinal types */ put skip;;
Unsupported type functions include BIND, CAST, NEW, RESPEC, SIZE, and VALUE.