The first line of the program specifies single-density graphics for 40 columns:

100LPRINTCHR$(27);"K";CHR$(@);CHR$(@;

The second line is the data that is printed as pin patterns. It uses the number 74 to produce one of the patterns shown above. The FOR-NEXT loop sends 40 columns of data.

Here is the second line of data:

2@g FOR X=1 TO 48: LPRINT CHR$(7L,);: NEXT X

That is the whole program. In BASIC, semicolons at the ends of the lines are very important; they prevent the computer from sending other codes after the ones you specify. In other languages you may have to use a special command to send a single code at a time. Run the program to see the result below. Although it is not as interesting as the examples at the beginning of this chapter, it shows exactly how the graphics mode works.

........ .... ........ ........

....... ............................ ......

WIDTH statements

Some software programs (including most versions of BASIC) automatically insert carriage return and line feed codes after every 80 or 130 characters. This is usually no problem with text, but can spoil your graphics. Two extra columns of graphics are printed in the middle of the ones you send, and two data numbers are left over and printed as text.

In some versions of BASIC you can prevent unwanted control codes in graphics by putting a WIDTH statement at the beginning of all graphics programs. The format in many forms of BASIC is either WIDTH “LPT1:“, 255 or WIDTH LPRINT 255. Check your software manual for the proper format.

Printing taller patterns

The next example shows how several lines of graphics can be formed into a figure taller than eight dots. It uses programming techniques for producing textured or repetitive patterns.

Using Software and Graphics

4-13