Graphics Programming Tips

Now that we’ve shown you how to design your own graphics, we’ll review and emphasize a few elements of graphics programming. As usual, we use MBASIC in the examples, but the principles apply to any programming language.

Semicolons and command placement

After the graphics command is issued, every number sent to the LX-80 is interpreted as a pin pattern and printed on paper. Therefore, you must be careful where you put graphics commands in your program.

For example, suppose you want a 50-column graphics line with the line spacing set to 7-dot. You might enter the following program:

20 LPRINT CHR$(27)“K”CHR$(50)CHR$(0)30 LPRINT CHR$( 27 ) ” 1"40 FOR G=l TO 50: LPRINT CHR$(74): NEXT G

This program has all the necessary elements. Line 20 has the command for single-density graphics and specifies 50 columns. (Remem- ber 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 9-2to 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 9-6.

Expected pattern

Actual result

 

 

 

 

Figure 9-6. Result of incorrect program

86