1.2.6 Sending your own printer commands
Withoutaprinter driver,sending controlcodes andEscape sequences toyour
printer properly requires someknowledge of aprogramming language like
BASIC or Pascal, orat least of how to put such codes into aprogram. With
programming languages,the computerdoesn’t act onthe commands you put
into aprogram untilyou tell it to run that program.
When you give acommand to the printer from acomputer program, you
normally enter each part ofthe command as aseparate character. This way
you don’t affect anything else happening on the computer. You often send
each code or character in the command by giving itsposition in the ASCII
table, as adecimal or hex number.
1.2.7A BASIC example
Here’s an example youcan type in right now, to clarify what we’re saying.
It’s written in Microsoft BASIC for acomputer that uses the MS-DOS
operating system, so if you have adifferent computer or BASIC you may
have to translate abit.
The LPRINT commands allsend data to the printer. If the data is something
youwant printedyoujust put itinquotationmarks. If thedataisacontrol code
youjust say where it is in the ASCII table, giving its position as aregular
decimal number.
BASIC usuallysends acarriage return after every 80 characters, to keep the
print position moving when it hits the end of aline. Unasked-for carriage
returns can mess up your printing, however, so it’sagood habit to put in a
WIDTH statement as shown. That lets usprint over the whole page area.
The<BEL> control code ASCII code7— is sent in BASIC as CHR$(7).
The<ESC> code itself is CHR$(27).And because we’re using the character
zas part of an <ESC> command, we type CHR$(112) instead of “z”.
So if you start BASIC and type these commands:
10