Char Type
The Char type represents a single character, just as it does in standard Pascal. You can cast any integer type to a character by using the Char type name in a type cast. Unlike some other type casts, the size of the integer value does not have to match the size of a Char.
You can write a character constant in several different ways:
As a string of length 1, e.g., ‘A’ (best for printable characters)
As a caret control character, e.g., ^A (good for ANSI control characters, but you should probably give the character a meaningful name, as shown here):
const TAB = ^I; CRLF = ^M^J;
As #
followed by an integer constant, e.g.,
#65
or #$41
(good for control
characters, e.g., #0 or #255)
By calling the Chr
function, e.g.,
Chr(65)
(best for converting integer variables to
characters)
By typecasting an integer, e.g., Char(65)
(same as
Chr
)