From Clomosy Docs
No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
<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> | |||
Returns the character for a specified ASCII value.<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> | |||
:''' | <b>Example</b><br> | ||
<b>TRObject Syntax</b><br> | |||
<pre> | |||
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'); | |||
} | |||
</pre> | |||
<b>Base Syntax</b><br> | |||
<pre> | |||
var | |||
tab : char; | |||
crlf : string; | |||
begin | |||
// Show the use of Chr | |||
tab := Chr(124); | |||
crlf := Chr(13)+Chr(10); | |||
ShowMessage('Hello '+tab+' World'); | |||
ShowMessage('Hello'+crlf+'World'); | |||
end; | |||
</pre> | |||
: | <b>Output:</b> | ||
<div class="alert alert-success" role="alert" data-bs-theme="light"> | |||
Hello | World<br> | |||
Hello<br> | |||
World | |||
</div> | |||
Revision as of 15:07, 4 October 2024
function Chr(X: Byte) : Char;
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
TRObject Syntax
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');
}
Base Syntax
var
tab : char;
crlf : string;
begin
// Show the use of Chr
tab := Chr(124);
crlf := Chr(13)+Chr(10);
ShowMessage('Hello '+tab+' World');
ShowMessage('Hello'+crlf+'World');
end;
Output:
Hello | World
Hello
World