9 Output Operations

Printer Control Functions

Many printers have a set of control functions which are accessed via unique single or multi-character control sequences. These ASCII character sequences can be sent separately to initialize particular functions such as bell, back spacing, or formfeed. The control sequences can also be embedded in text to be printed, or a combination of both methods can be used.

The CHR$ string function is most often used to send control sequences to a printer. For example, most printers respond to an ASCII BS character by backspacing one character. The BS character has an ASCII-decimal value of 8, allowing this sequence to backspace and underline text.


10   PRINTER IS 0
20   PRINT "HERE'S HOW TO BACKSPACE AND UNDERLINE.";
30   FOR Char=1 TO 24
40     PRINT CHR$(8);
50   NEXT Char
60   PRINT " ____________    ____________    ____________  "
70   END

HERE'S HOW TO BACKSPACE AND UNDERLINE.
Use of the ASCII ESC (escape) character allows more complex functions to be controlled on the printer. For example, the sequence ESC z initiates the printer's self-test routine. This statement sends those two ASCII characters to the printer:

10  PRINT CHR$(27)&"z"
Use of escape sequences allows turning on and off various modes. This statement shows how to control the printer's underline mode:

100  PRINT "HERE'S ANOTHER WAY TO ";CHR$(27)&"dD";
"UNDERLINE";CHR$(27)&"dA";"."

HERE'S ANOTHER WAY TO UNDERLINE
Consult the printer's documentation for more information on printer control codes, escape sequences, and printer control.


Eloquence Language Manual - 19 DEC 2002