From Clomosy Docs

No edit summary
No edit summary
Line 1: Line 1:
function Ord(Arg AnsiChar | Char | WideChar | Enumeration | Integer):Integer;
<div class="alert alert-ligth border border-3 border-primary-subtle rounded-5 p-4 shadow-sm" role="alert">
function Ord(X: Char):Integer;
</div>
 
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.
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.


'''Example:'''<br>
<b>Example</b><br>
:'''Base Syntax'''
<b>TRObject Syntax</b><br>
  var
<pre>
    S  : AnsiChar;
var
    M  : Char;
  S  : AnsiChar;
    W  : WideChar;
  M  : Char;
    control  : Boolean;
  W  : WideChar;
    number  : Integer;
  control  : Boolean;
    I64 : Int64;
  number  : Integer;
 
  I64 : Int64;
  begin
 
{
    // Set type values
    := 'S';
  // Set type values
    := 'M';
  S  = 'S';
    := 'W';
  M  = 'M';
    control  := True;
  W  = 'W';
    number  := 22;
  control  = True;
    I64 := 64;
  number  = 22;
 
  I64 = 64;
    // Show value
    ShowMessage('S = '+IntToStr('''Ord'''(S)));
  // Show value
    ShowMessage('M = '+IntToStr('''Ord'''(M)));
  ShowMessage('S = '+IntToStr(Ord(S)));
    ShowMessage('W = '+IntToStr('''Ord'''(W)));
  ShowMessage('M = '+IntToStr(Ord(M)));
    ShowMessage('control = '+IntToStr('''Ord'''(control)));
  ShowMessage('W = '+IntToStr(Ord(W)));
    ShowMessage('number = '+IntToStr('''Ord'''(number)));
  ShowMessage('control = '+IntToStr(Ord(control)));
    ShowMessage('I64 = '+IntToStr('''Ord'''(I64)));
  ShowMessage('number = '+IntToStr(Ord(number)));
 
  ShowMessage('I64 = '+IntToStr(Ord(I64)));
  end;
 
}
:'''TRObject Syntax'''
</pre>
 
<b>Base Syntax</b><br>
  var
<pre>
    S  : AnsiChar;
var
    M  : Char;
  S  : AnsiChar;
    W  : WideChar;
  M  : Char;
    control  : Boolean;
  W  : WideChar;
    number  : Integer;
  control  : Boolean;
    I64 : Int64;
  number  : Integer;
 
  I64 : Int64;
  {
 
begin
    // Set type values
    S  = 'S';
  // Set type values
    M  = 'M';
  := 'S';
    W  = 'W';
  := 'M';
    control  = True;
  := 'W';
    number  = 22;
  control  := True;
    I64 = 64;
  number  := 22;
 
  I64 := 64;
    // Show value
    ShowMessage('S = '+IntToStr('''Ord'''(S)));
  // Show value
    ShowMessage('M = '+IntToStr('''Ord'''(M)));
  ShowMessage('S = '+IntToStr(Ord(S)));
    ShowMessage('W = '+IntToStr('''Ord'''(W)));
  ShowMessage('M = '+IntToStr(Ord(M)));
    ShowMessage('control = '+IntToStr('''Ord'''(control)));
  ShowMessage('W = '+IntToStr(Ord(W)));
    ShowMessage('number = '+IntToStr('''Ord'''(number)));
  ShowMessage('control = '+IntToStr(Ord(control)));
    ShowMessage('I64 = '+IntToStr('''Ord'''(I64)));
  ShowMessage('number = '+IntToStr(Ord(number)));
 
  ShowMessage('I64 = '+IntToStr(Ord(I64)));
  }
end;
</pre>


'''Output:'''<br>
'''Output:'''<br>
Line 69: Line 73:
  number = 22
  number = 22
  I64 = 64
  I64 = 64
<b>Output:</b><br>
<div class="alert alert-success" role="alert" data-bs-theme="light">
S = 83<br>
M = 77<br>
W = 87<br>
control = -1<br>
number = 22<br>
I64 = 64
</div>
<h2> See Also </h2>
* [[System_Library#Math_Functions | Math Functions]]

Revision as of 12:57, 7 October 2024

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.

Example
TRObject Syntax

var
   S   : AnsiChar;
   M   : Char;
   W   : WideChar;
   control   : Boolean;
   number   : Integer;
   I64 : Int64;
 
{
 
   // Set type values
   S   = 'S';
   M   = 'M';
   W   = 'W';
   control   = True;
   number   = 22;
   I64 = 64;
 
   // Show value
   ShowMessage('S = '+IntToStr(Ord(S)));
   ShowMessage('M = '+IntToStr(Ord(M)));
   ShowMessage('W = '+IntToStr(Ord(W)));
   ShowMessage('control = '+IntToStr(Ord(control)));
   ShowMessage('number = '+IntToStr(Ord(number)));
   ShowMessage('I64 = '+IntToStr(Ord(I64)));
 
}

Base Syntax

var
   S   : AnsiChar;
   M   : Char;
   W   : WideChar;
   control   : Boolean;
   number   : Integer;
   I64 : Int64;
 
begin
 
   // Set type values
   S   := 'S';
   M   := 'M';
   W   := 'W';
   control   := True;
   number   := 22;
   I64 := 64;
 
   // Show value
   ShowMessage('S = '+IntToStr(Ord(S)));
   ShowMessage('M = '+IntToStr(Ord(M)));
   ShowMessage('W = '+IntToStr(Ord(W)));
   ShowMessage('control = '+IntToStr(Ord(control)));
   ShowMessage('number = '+IntToStr(Ord(number)));
   ShowMessage('I64 = '+IntToStr(Ord(I64)));
end;

Output:

S = 83
M = 77
W = 87
control = -1
number = 22
I64 = 64

Output:

See Also