From Clomosy Docs

No edit summary
No edit summary
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
function Chr(IntValue Integer):AnsiChar;
<div class="alert alert-ligth border border-3 border-primary-subtle rounded-5 p-4 shadow-sm" role="alert">
function Chr(X: Byte) : Char;
</div>


The Chr function converts an IntValue integer into either an AnsiChar or WideChar as appropriate.<br>
Returns the character for a specified ASCII value.<br>


'''Example:'''<br>
Chr returns the character with the ordinal value (ASCII value) of the byte-type expression, X. The Byte parameter is an unsigned integer value large enough to represent a character. Word or UInt16 is also appropriate, because now that the string type is Unicode, a character is represented by two bytes. <br>
  '''var'''
 
  tab  : char;
<b>Example</b><br>
  crlf : string;<br>
<pre>
  '''begin'''
  var
  // Show the use of Chr
  tab  : char;
  tab := '''Chr'''(124);
  crlf : string;
  crlf := Chr(13)+Chr(10);
   
  ShowMessage('Hello '+tab+' World');
{
  ShowMessage('');
  // Show the use of Chr
  ShowMessage('Hello'+crlf+'World');
  tab = Chr(124);
  ShowMessage('');<br>
  crlf = Chr(13)+Chr(10);
'''end;'''
  ShowMessage('Hello '+tab+' World');
  ShowMessage('Hello'+crlf+'World');
}
</pre>
 
<b>Output:</b>
<div class="alert alert-success" role="alert" data-bs-theme="light">
Hello | World<br>
Hello<br>
World
</div>
 
<h2> See Also </h2>
* [[System_Library#String_Functions | String Functions]]
{{#seo:|title=Chr Using in Clomosy - Clomosy Docs}}
{{#seo:|description=Explore the Chr function in Clomosy to convert ASCII values into characters, with examples demonstrating its use in string manipulation and formatting.}}

Latest revision as of 15:16, 24 December 2024

Returns the character for a specified ASCII value.

Chr returns the character with the ordinal value (ASCII value) of the byte-type expression, X. The Byte parameter is an unsigned integer value large enough to represent a character. Word or UInt16 is also appropriate, because now that the string type is Unicode, a character is represented by two bytes.

Example

 var
   tab  : char;
   crlf : string;
 
 {
   // Show the use of Chr
   tab = Chr(124);
   crlf = Chr(13)+Chr(10);
   ShowMessage('Hello '+tab+' World');
   ShowMessage('Hello'+crlf+'World');
 }

Output:

See Also