3 – 4 Programming
Computers cannot understand letters. They use only numbers, more
specifically, binary numbers (1s and 0s). When carrying out an LPRINT
command, the computer sends the printer a code number for each
character (letter, symbol, punctuation mark) within the quotation marks.
As the printer receives each number, it prints the dot pattern associated
with that number.
The American Standard Code for Information Interchange (better known
as ASCII) is the standard code used by computers. Appendix D gives the
ASCII code numbers along with their hexadecimal, binary, and decimal
equivalents. You can enter these ASCII numbers directly in your LPRINT
statement by using the CHR$ (Character String) function.
The CHR$ command sends the ASCII command in parentheses to the
printer. For example, we can write a program this way:
LPRINT CHR$(79);CHR$(75);CHR$(73)
This is obviously a tedious way to write, but you need to understand the
concept when you want to use certain commands.
Keep in mind that there is a big difference between ASCII code numbers
and numbers that are printable characters. For example, if you want to
print the number 1 using an LPRINT statement, you would type this:
LPRINT CHR$(49)
You can also print numbers and symbols by putting them within quotes,
like this:
LPRINT “1”
So far, we have discussed printable characters, ASCII codes located
between decimal 32 and decimal 127. Non-printable codes, located
between 0 and 31, do not tell the printer to print something. They
instruct the printer how to print something. The ASCII chart in the back
of this handbook shows that these codes have abbreviations, such as FF
and US. Some of these abbreviations make sense (FF, for instance,
stands for form feed) but others do not unless you are a
telecommunications expert.