Sending Control Codes to the Printer

The short program that follows illustrates the concepts of control codes and ESCape sequences. This exercise may help you make better use of this chapter and the next. Type and run the program. It should produce the printout you see below it. After the printout you’ll find a detailed description of the operation of the program.

10 LPRINT "BASIC programs for the"

20 LPRINT CHR$(76)CHR$(81)CHR$(45);

25 LPRINT CHR$(56)CHR$(48)CHR$(48);

30 LPRINT " and LQ-1000"

40 LPRINT "W1 "CHR$(87)CHR$(49)

50 LPRINT CHR$(27)"W1";"Double-width print"

60 LPRINT "Still double-width"

Basic programs for theLQ-800 and LQ-1000W1 W1
D ou b l e - w id t h p ri n t
S ti l l d o ub l e - w id t h

In each line LPRINT signals that the rest of the information on the line is to be sent to the printer. In lines 10 and 30 the letters inside the quotation marks are printed just as they appear in the program.

Lines 20-25 show an alternate way of printing characters. They use the CHR$ (character string) function with the decimal code for each letter to print “LQ-800.”

Line 40 prints the characters W1 using the two different methods (quotation marks and the character string function). Line 50 shows that if the ESCape code, which is CHR$(27) in BASIC, comes before the characters W1, those characters are not printed. Instead, they become part of the ESCape sequence that turns on double-width printing, which is demonstrated with the letters in quotation marks after the ESCape sequence. Line 60 shows that the double-width mode stays on for more than one line.

This program is only an introduction. The demonstration pro-

grams that follow allow you to see many more of the features of your LQ in action.

5-4