1.2.6 Sending your own printer commands
Without a printer driver, sending control codes and Escape sequences to your printer properly requires some knowledge of a programming language like BASIC or Pascal, or at least of how to put such codes into a program. With programming languages, the computer doesn’t act on the commands you put into a program until you tell it to run that program.
When you give a command to the printer from a computer program, you normally enter each part of the command as a separate 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 its position in the ASCII table, as a decimal or hex number.
1.2.7A BASIC example
Here’s an example you can type in right now, to clarify what we’re saying. It’s written in Microsoft BASIC for a computer that uses the
The LPRINT commands all send data to the printer. If the data is something you want printed youjust put it inquotationmarks. If thedataisacontrol 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.
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 z as part of an <ESC> command, we type CHR$(112) instead of “z”.
So if you start BASIC and type these commands:
10