Mega Code Archive

 
Categories / Delphi / Functions
 

Ord - provides the ordinal value of an integer, character or enum system unit

1 function Ord ( Arg : AnsiChar | Char | WideChar | Enumeration | Integer ) : Integer; 2 function Ord ( Arg : Int64 ) : Int64; Description The Ord function returns an integer value for any ordinal type Arg. It is principally used to convert characters or enumerations into their numeric equivalents. Related commands Char Variable type holding a single character Chr Convert an integer into a character Val Converts number strings to integer and floating point values Example code : Illustrate all Ord types var A : AnsiChar; C : Char; W : WideChar; E : Boolean; I : Integer; I64 : Int64; begin // Set the ordinal type values A := 'A'; C := 'C'; W := 'W'; E := True; I := 22; I64 := 64; // And show the value of each ShowMessage('A = '+IntToStr(Ord(A))); ShowMessage('C = '+IntToStr(Ord(C))); ShowMessage('W = '+IntToStr(Ord(W))); ShowMessage('E = '+IntToStr(Ord(E))); ShowMessage('I = '+IntToStr(Ord(I))); ShowMessage('I64 = '+IntToStr(Ord(I64))); end; Show full unit code A = 65 C = 67 W = 87 E = 1 I = 22 I64 = 64