[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 ORD                  Return Ordinal Value of Set Member              pp 142

 Syntax:  Ord (Var) ;

 Type:    Integer

 Form:    Function

 Purpose: Returns the ordinal number of the value Var in the set defined by
          the type of Var.   An ordinal number is a number indicating a
          position in an ordered series.

 Notes:   Ord (Var) is the same as Integer (Var).  Var may be of any
          scalar type except Real.


 ----------------------------------------------------------------------------


 Usage:
       TYPE
          Spectrum = (Red,Orange,Yellow,Green,Blue,Indigo,Violet) ;
          Days     = (NoDay,Mon,Tue,Wed,Thu,Fri,Sat,Sun);
       VAR
          Int      : Integer ;

       BEGIN
          WriteLn (Ord (Red))    ;  { 0 ordinal of enumerated type Spectrum }
          WriteLn (Ord (Violet)) ;  { 6 ordinal of enumerated type Spectrum }
          WriteLn (Ord ('A'))    ;  { 65 ordinal of type CHAR               }
          Int :=  (Ord (False))  ;  { 0 ordinal of Boolean type             }
          Int :=  (Ord (True))   ;  { 1 ordinal of Boolean type             }
          Int :=  (Ord (NoDay))  ;  { 0 ordinal of enumerated type Days     }
          Int :=  (Ord (Sun))    ;  { 7 ordianl of enumerated type Days     }
       END.

See Also: Byte Char Chr
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson