Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Turbo Pascal - <b> ord return ordinal value of set member pp 142</b> http://www.X-Hacker.org [<<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

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson