Figure 6-4. Result of incorrect program

Once the graphics mode is in effect, every number sent to the printer is interpreted as a dot pattern and printed on the paper. Since no semicolon appears at the end of line 20, the numbers 13 and 10- the codes for carriage return and line feed-are sent to the printer after CHR$(0), and interpreted as dot patterns.

Line 30, the command for 9-dot line spacing is also interpreted as a dot pattern. Since no semicolon appears at the end of this line, the numbers 13 and 10 are sent again and printed as pin patterns as well.

In line 40 nothing is sent to the printer until after the LPRINT. Then the desired dot pattern-CHR$(74)-is finally sent. Again, since no semicolon is after CHR$(74), 13 and 10 are sent each time the loop is executed.

After the P-80 has received all the numbers that are reserved by the graphics command-50 in this case-it leaves the Graphics mode and resumes interpreting numbers in the normal way. Because the incorrect program has sent many extra numbers, mainly 10s and 13s, the 50 reserved columns are filled before the loop in line 30 has been executed 50 times. Therefore, during the last passes of the loop, the P-80 interprets CHR$(74) as the ASCI code for “J”. It prints a “J” and issues a carriage return and line feed for each of the last 35 passes of the loop.

To make the program work correctly, put the line-spacing command in line 10, delete line 30, and add two semicolons: one at the end of line 20 and one between CHR$(74) and the colon in line 40.

This program is explained in detail so that you remember two important points about using the graphics command:

Use semicolons to prevent the P-80 from printing carriage return and line feed codes as pin patterns.

49