If you are using Microsoft BASIC: 20 LPRINT CHR$(27)"K"CHR$(50)CHR$(0) 30 LPRINT CHR$(27)" 1" 40 FOR G= 1 TO 50: LPRINT CHR$(74): NEXT G This program has all the necessary elements. Line 20 has the com- mand for single-density graphics and specifies 50 columns. (Remember that you must use two numbers to reserve columns even if you only need the first one.) Line 30 has the correct command for 7-dot line spacing, and line 40 calls for the printing of a pin pattern 50 times.
(If you wish, refer back to Figure 7-2 to see a representation of the pin pattern that 74 produces.) Although this program has all the necessary elements, it will not give you the single pin pattern that you want, as you can see in the partial printout in Figure 7-6. Figure 7-6. Result of incorrect program What went wrong? To help you understand the graphics command and avoid some of the more common errors made with it, we'll look at 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 pat- terns. 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 7 -7 is an enlarged representation of the first 14 columns of the printout.
In this figure you can see exactly how the printer reacted to the first part of the incorrect program. :::: ;.; :~.;..;~:::::-;::;;;· ·:::.:~~;::::.:;;: Expected pattern J J J Actual result