Epson FX-286 User Manual - Page 89

String variables

Page 89 highlights

Remember to use the proper format for your system for the WIDTH statement in line 90. In this program the number 128 in the DATA statements signals the end of a print line. This is the reason for the IF-THEN statement in line 610 that skips to line 650 and causes a line feed. The other special technique used in this program is found in lines 620 and 630. Since some of the data numbers are repeated many times, using negative DATA numbers for repetitions saves typing. Line 620 tests for a negative number, and if it finds one, reads the next two numbers and prints their pin patterns the number of times indicated by the negative number. For example, when the minus 6 in line 800 is read, the program then reads the next two numbers (8 and 0) and sends them to the printer 6 times. This feature is not a necessary part of the program, but it does allow you to type fewer data numbers. Otherwise the program is a straightforward graphics program that uses seven-dot line spacing and reads numbers from DATA statements and sends them to the printer. If you want to see the figure in other densities, change the "Y" in line 600 to "L" or "Z". String variables In a long and complicated graphics program, typing in the graphics command or repetitive data numbers over and over can become timeconsuming. 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 exer cise earlier in the chapter except for the string variables. 10 WIDTH "LPT1:",255 20 G$=CHR$(27)+"K"+CHR$(100)+CHR$(0) 30 A$=CHR$(85)+CHR$(42) 40 B$=CHR$(42)+CHR$(85) 50 LPRINT CHR$(27)"A"CHR$(7) 60 FOR R=1 TO 3 70 LPRINT G$; 80 FOR X=1 TO 50: LPRINT A$;: NEXT X 90 LPRINT 100 LPRINT G$; 110 FOR X=1 TO 50: LPRINT B$;: NEXT X 120 LPRINT: NEXT R 130 LPRINT CHR$(27)"@" 6-14

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208
  • 209
  • 210
  • 211
  • 212
  • 213
  • 214
  • 215
  • 216
  • 217
  • 218
  • 219
  • 220
  • 221
  • 222
  • 223

Remember to use the proper format for your system for the
WIDTH statement in line
90.
In this program the number
128
in the DATA statements signals the
end of a print line. This is the reason for the IF-THEN statement in line
610 that skips to line 650 and causes a line feed.
The other special technique used in this program is found in lines
620 and 630. Since some of the data numbers are repeated many
times, using negative DATA numbers for repetitions saves typing.
Line 620 tests for a negative number, and if it finds one, reads the next
two numbers and prints their pin patterns the number of times indi-
cated by the negative number.
For example, when the minus 6 in line 800 is read, the program then
reads the next two numbers (8 and 0) and sends them to the printer 6
times. This feature is not a necessary part of the program, but it does
allow you to type fewer data numbers.
Otherwise the program is a straightforward graphics program that
uses seven-dot line spacing and reads numbers from DATA statements
and sends them to the printer. If you want to see the figure in other
densities, change the “Y” in line 600 to “L” or “Z”.
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 exer
cise earlier in the chapter except for the string variables.
10 WIDTH "LPT1:",255
20 G$=CHR$(27)+"K"+CHR$(100)+CHR$(0)
30 A$=CHR$(85)+CHR$(42)
40 B$=CHR$(42)+CHR$(85)
50 LPRINT CHR$(27)"A"CHR$(7)
60 FOR R=1 TO
3
70 LPRINT G$;
80 FOR X=1 TO 50: LPRINT A$;: NEXT X
90 LPRINT
100 LPRINT G$;
110 FOR X=1 TO
50:
LPRINT B$;: NEXT X
120 LPRINT: NEXT R
130
LPRINT CHR$(27)"@"
6-14