RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
System.Ord Function

Returns the ordinal value of an ordinal-type expression.

Pascal
procedure Ord(X);
C++
Ord( X);

System

X is a Delphi ordinal-type expression. The result is the ordinal position of X; its type is the smallest standard integer type that can hold all values of X's type. 

Ord cannot operate on Int64 values.  

Delphi Examples: 

 

{
This example displays the ordinal value for different enumerations.
}
procedure TForm1.Button1Click(Sender: TObject);
type
   Colors = (RED,BLUE,GREEN);
var
  S: string;
begin
  S := 'BLUE has an ordinal value of ' + IntToStr(Ord(BLUE)) + #13#10;
  S := S + 'The ASCII code for "c" is ' + IntToStr(Ord('c')) +  ' decimal';
  MessageDlg(S, mtInformation, [mbOk], 0, mbOK);
end;

 

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!