From Clomosy Docs

No edit summary
No edit summary
 
(3 intermediate revisions by 2 users not shown)
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'''
  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;


:'''TRObject Syntax'''
<pre>
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)));
}
</pre>


  var
<b>Output:</b><br>
    S  : AnsiChar;
<div class="alert alert-success" role="alert" data-bs-theme="light">
    M  : Char;
S = 83<br>
    W  : WideChar;
M = 77<br>
    control  : Boolean;
W = 87<br>
    number  : Integer;
control = -1<br>
    I64 : Int64;
number = 22<br>
 
I64 = 64
  {
</div>
 
    // 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)));
 
  }


'''Output:'''<br>
<h2> See Also </h2>
S = 83
* [[System_Library#Math_Functions | Math Functions]]
M = 77
{{#seo:|title=Ord Usage Guide - Clomosy Docs}}
W = 87
{{#seo:|description=Explore the Ord function in Clomosy. A simple yet powerful tool to handle character-to-numeric conversions for streamlined app logic.}}
control = -1
number = 22
I64 = 64

Latest revision as of 13:06, 24 December 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

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)));
 
}

Output:

See Also