9 Output Operations
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 UNDERLINEConsult the printer's documentation for more information on printer control codes, escape sequences, and printer control.