SmartPascal
Ord
Function
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
// Full Unit code.
// -----------------------------------------------------------
// You must store this code in a unit called Unit1 with a form
// called Form1 that has an OnCreate event called FormCreate.
 
unit Unit1;
 
interface
 
uses
  // The System unit does not need to be defined
  SysUtils,
  Forms, Dialogs;
 
type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  end;
 
var
  
Form1: TForm1;
 
implementation
{$R *.dfm} // Include form definitions
 
procedure TForm1.FormCreate(Sender: TObject);

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;
 
end.
Hide full unit code
   A = 65
   C = 67
   W = 87
   E = 1
   I = 22
   I64 = 64