Graphics

Printing simple patterns

The first example is just a simple program to show you how a graphics command, column reservation numbers, and data can be used in a BASIC program.

Type in and run the following program; be especially careful to include all semicolons. The program produces the printout you see below.

10 WIDTH "LPT1:",255

20 LPRINT CHR$(27);"*n ;cHR$(O);CHR$(4O);cHR$(o); jOFORX=lTO40

40LPRINTCHR$(1'10); 50 NEXT X

Line 20 specifies single-density graphics mode and also reserves 40 columns for ‘graphics. Line 30 begins a loop to supply 140 bytes of data. Line 40 contains the number 170, which produces the first pin pattern shown in the section on pin labels, and line 50 finishes the loop.

Note: Some software programs (including most version of BASIC) automatically insert carriage return and line feed codes after every 80 or 130 characters. This is usually no problem with text, but it can spoil your graphics. For every CR-LF pair inserted in your program, 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 this unwanted control code insertion 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.

4-14 Software and Graphics