What went wrong? To help you understand the graphics command and avoid some of the more common errors made with it, we’ll examine this program in detail.

First look at line 20. ESCape “K” calls for single-density graphics, and the two CHR$ numbers specify 50 columns of dots. Once that command is given, every number sent to the printer is interpreted as a pin pattern and printed on the paper. Since there is no semicolon at the end of the line, the numbers 13 and 10-the codes for carriage return and line feed-are sent to the printer after CHR$(0). Because the graphics command has been issued, these codes are printed as pin patterns.

Line 30 would normally be the command for 7-dot line spacing, but since the graphics mode is still in effect, the command is interpreted by the printer as two pin patterns: 27 and 49 (the ASCII codes for ESCape and “1”). Since there is no semicolon at the end of this line, the numbers 13 and 10 are sent again, and again they are printed as pin patterns.

In line 40 nothing is sent to the printer until after the LPRINT. Then the desired pin pattern-74-is finally sent, but since no semicolon is after it, 13 and 10 are sent next each time the loop is executed.

Figure 9-7 is an enlarged representation of the first 13 columns of the printout. In this figure you can see exactly how the printer reacted to the first part of the incorrect program.

128

64

32

16

8

4

2

1

13

2 7

1 3

74

10

13

74

 

10

49

10

13

74

10

Figure 9-7. Pin patterns of incorrect program

85