You may also wonder why the program prints not only the different pin patterns but also the character “J” a number of times. The reason lies in the number of columns you reserved with the graphics command. After the
Since the incorrect program has sent many extra numbers, mainly 10s and 13s, the 50 columns reserved are filled before the loop in line 40 has been executed 50 times. Therefore, during the last passes of the loop the
If you want 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.
We have explained this incorrect program in detail so that you will remember two important tips about using the graphics command:
•Use semicolons to prevent the
•Do not put any other commands between the graphics command and its data.
Our example should help you understand the graphics mode better and may help you find the problem when one of your own programs gives you unexpected results.
String variablesIn a long and complicated graphics program, typing in the graphics command or repetitive data numbers over and over can become time- consuming. You can avoid much of the repetitive typing by storing commands and data in string variables.
Look at the program below. It is the same as the
88