Epson GX-80 Operating Manual page 40

Table of Contents

Advertisement

This incorrect program has been explained in detail so that you will
remember two important tips about using the graphics command:
• Use semicolons to prevent the GX-80 from printing carriage
return and line feed codes as pin patterns in BASIC programs,
and take similar steps in other programming languages.
• Do not putany 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 variables
In 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 multiple-line
exercise earlier in the chapter except for the string variables.
5 PRINT CHR$(4)"PR**l"
10 G$=CHR$(27)+"K"+CHR$(100)+CHR$(0)
20 A$=CHR$(85)+CHR$(42)
30 B$=CHR$(42)+CHR$(85)
40 PRINT CHR$(27)"1";
50 FOR R=l TO 3
60 PRINT G$;
70 FOR X=l TO 50:PRINT A$; :NEXT X
80 PRINT
90 PRINT G$;
100 FOR X=l TO 50:PRINT B$; :NEXT X
110 PRINT :NEXT R
120 PRINT CHR$(27)"@"
125 PRINT CHR$(4)"PRn0"
Notice that the first line stores the whole graphics command in a
single string variable. In order to do this you must put plus signs
between the elements of the command. Once you have done this at
the beginning of the program, each time you enter PRINT G$; you
have issued the graphics command. Lines 20 and 30 do the same
thing with the data used in this program. As you can see, the use of
string variables saves some typing even in this short program. In a
long program it can save you much more time and effort.
70
Graphics and low ASCII codes
Sending a few of the codes between
O
and 31 with BASIC or another
programming language can cause problems on_ some computer sys-
tems. The problem is that most computer systems handle some of
these codes in a special way instead of delivering them to the
printer.
For example, one computer system handles form feeds by itself. It
counts lines to keep track of the top of page. If a program sends the
ASCII code for form feed (12) to the printer, the computer system
intercepts it and sends instead the code for line feed (10) several
times. If you are in a graphics mode with this system and send a 12
to fire pins 3 and 4, the computer system will intercept that 12 and
send several 10s instead. You can see how this would ruin your
graphics. You would get pins 2 and 4 (whose sum is 10) several times
instead of pins 3 and 4 only once.
71

Advertisement

Table of Contents
loading

Table of Contents