A BASIC example
Here’s an example you can typo in right now, to clarify what we’re saying.
It’s written in Microsoft BASIC for a computer that uses the MS-DOS
operating system, so if you have a different computer or BASIC you may
have to translate a bit. We’ll show commands the way they’re written for an
Epson dot-matrix printer because your Star LaserPrinter 8 understands those
commands.
The LPRINT commands all send data to the printer. If the data is something
you want printed you just put it in quotation marks. If the data is a control
code you just say where it is in the ASCII table, giving its position as a regular
decimal number.
BASIC usually sends a carriage return after every 80 characters, to keep the
print position moving when it hits the end of a line. Unasked-for carriage
returns can mess up your printing, however, so it’s a good habit to put in a
WIDTH statement as shown. That lets us print over the whole page area.
The cBEL> control code - ASCII code 7 - is sent in BASIC as CHR$(7).
The <ES0 code itself is CHR$(27). And because we’re using the character
4 as part of an &SC> command, we type CHR$(52) instead of “4”.
So if you start BASIC and type these commands:
NEW
10 )
EXAMPLE
20 WIDTH "LPT1:",255
30 LPRINT CHR$(7)
40 LPRINT CHR$(27);CHR$(52)
50 LPRINT "ITALICS!"
60 END
RUN
you make the printer (in EX-800 mode) first sound its bell- most people
call it a beeper- and then print the line:
ITALICS!
Generally, when you send a control or Escape code it stays active until you
deactivate it. That’s what happens in line 40 of our program above. All
subsequent text will be italicized until you change it back to upright again.
10
-