Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
Chr Function
◄Summary► ◄Details► ◄Example► ◄Back►
Argument
number Integer expression in the range 0..255, representing
ASCII code
Returns
Char ASCII character associated with a number
Description
The Chr function returns the ASCII character associated with a
number. Chr accepts an integer expression of any type and returns
the character with ASCII value equal to the expression value.
The Ord function acts as the inverse of Chr, returning the ASCII
code for a given character.
Use Chr to perform the inverse of the UpCase function. Chr returns
a lowercase letter when 32 is added to the ASCII code for the
uppercase form of the letter. For example, to return the lowercase
version of an uppercase letter stored in character variable ch:
result := Chr( Ord( ch ) + 32 );
Use Chr to represent characters that cannot be expressed literally.
For example, to produce the character for the bell sound:
Write( Chr( 7 ) );
Use Chr to change the length of a Pascal string. The ordinal value
of the character at index zero in a Pascal string stands for the
string length. For example, to shorten a string variable s by one
character:
s[0] := Chr( Length( s ) - 1 );
To change string length regardless of the type of string, use
the Delete procedure.