This page explains a basic Pascal instruction. If you want to see how to make your own instructions, see Procedures and Functions.
This article is part of the Getting Started series |
|
Like the strings, the chars are variables that contain only one character. They are declared as it follows:
a,b,c,d,e : char;
Char functions[]
Chars are easy to manipulate and can be altered by many functions. Note: these functions work also when manipulating separate characters in a character string.
UPCASE and LOWERCASE[]
The upcase function turns a char that contains a low-case letter into a up-case letter. For example:
c:='a';
c2:=upcase(c); {c2 will be 'A'}
The lowercase function tunrs char that contains an up-case letter into a low-case letter.(Free Pascal)
for example;
b:='R';
b2:=lowercase(b) ; {b2 will be 'r'}
ORD[]
The ord function returns the ASCII numeric value of the char. Remember:
- ord('A')=65
- ord('Z')=90
- ord('a')=97
- ord('z')=122
- ord('0')=48
- ord('9')=57
CHR[]
The chr function is the reverse of the ord function. It turns the ASCII code of the character into the character itself. Remember:
- chr(65)='A'
- chr(90)='Z'
- chr(97)='a'
- chr(122)='z'
- chr(48)='0'
- chr(57)='9'
See also[]
- Script:Caesar cipher
- Script:Lowcase a string