-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathtest.html
More file actions
325 lines (287 loc) · 9.33 KB
/
test.html
File metadata and controls
325 lines (287 loc) · 9.33 KB
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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="basicode.js"></script>
</head>
<body>
<script type="text/basicode">
1000 GOTO 20: REM World greeter
1010 PRINT "Hello, World!"
1020 GOTO 950
30000 REM This program greets the world.
</script>
<!-- on Chrome, this does not work for local files due to origin restrictions -->
<script type="text/basicode" src="hello.bc"></script>
<script type="text/basicode">
1000 A=1:GOTO20
1010 GOSUB100:HO=10:VE=1:GOSUB110:SR$="Press a key.":GOSUB150:GOSUB 250:SD=30:GOSUB450
1012 GOSUB 280
1015 GOSUB100:HO=10:VE=2:GOSUB110:SR$="Type something.":GOSUB150
1020 INPUTA$:HO=10:VE=3:GOSUB110:PRINT"you typed: ";A$
1030 INPUT A: PRINT "value: "; A
1040 GOSUB 120: PRINT HO; VE;
1050 SR$="Testy": GOSUB 150
1060 HO=0: VE=4: GOSUB 220: SR$=IN$: GOSUB 150: PRINT IN
1080 SR=0.5: GOSUB 300: PRINT "["+SR$+"]"
1090 SR=0.5: CN=5: CT=10: GOSUB 310: PRINT "["+SR$+"]"
1100 SR=12345: CN=0: CT=10: GOSUB 310: PRINT "["+SR$+"]"
1110 SR=12345: CN=5: CT=10: GOSUB 310: PRINT "["+SR$+"]"
1120 SR$="printer": GOSUB 330: GOSUB 350: GOSUB 360
1130 SR$="test": GOSUB 350
1140 SP=60: SD=2: SV=15: GOSUB 400
1150 SP=80: SD=3: SV=7: GOSUB 400
1160 SP=60: SD=4: SV=1: GOSUB 400
2000 GOTO 950
</script>
<script type="text/basicode">
1000 A=1: GOTO 20
1010 PRINT "basicode test 2"
1070 GOTO 950
</script>
<script type="text/basicode">
1000 A=2:REM test program
1010 GOTO 1030
1020 PRINT"this should not be visible"; A: REM ignore this
1030 PRINT "OK": GOTO 950
1040 PRINT "ignore me"
30000 REM BASICODE test program:
30020 REM a program that tests REMs
</script>
<script type="text/basicode">
1000 A=2:REM test program 2
1010 B=5: PRINT "!": GOSUB 10000
1020 B=6: PRINT "!": GOSUB 10000
1025 B=7: PRINT "!": GOSUB 10000
1030 GOTO 950
10000 PRINT B;
10010 RETURN
</script>
<script type="text/basicode">
1000 A=2:REM test program 2b
1010 B=5: IF 1 THEN GOSUB 10000: B=6: GOSUB 10000: PRINT "!"
1025 B=7: GOSUB 10000
1030 GOTO 950
10000 PRINT B;
10010 RETURN
</script>
<script type="text/basicode">
1000 A=2:REM test program 3
1010 B=10: GOTO 1030: B=600
1020 B=1000
1030 PRINT B: GOTO 950
</script>
<script type="text/basicode">
1000 PRINT "if test":
1010 A=0: IF A THEN PRINT 1;
1020 PRINT 2;: IF NOT A THEN PRINT 3;
1030 PRINT 4: GOTO 950
</script>
<script type="text/basicode">
1000 PRINT "if test 2":
1010 IF 0=0 THEN PRINT 1;: IF 0=0 THEN PRINT 2;: IF 0=1 THEN PRINT "FAIL"
1030 PRINT 3: GOTO 950
</script>
<script type="text/basicode">
1000 :
1010 A=2: ON A GOTO 1020, 1030, 1040
1015 PRINT "None": GOTO 950
1020 PRINT 1020: GOTO 950
1030 PRINT 1030: GOTO 950
1040 PRINT 1040: GOTO 950
</script>
<script type="text/basicode">
1000 :
1010 A=3: ON A GOSUB 1020, 1030, 1040
1015 PRINT "back": GOTO 950
1020 PRINT 1020;: RETURN
1030 PRINT 1030;: RETURN
1040 PRINT 1040;: RETURN
</script>
<script type="text/basicode">
1000 :
1010 IF 0=0 THEN 1040
1020 PRINT "no": GOTO 950
1040 PRINT "yes": GOTO 950
</script>
<script type="text/basicode">
1000 :
1010 IF 0=0 THEN GOTO 1040: PRINT "certainly not"
1020 PRINT "no": GOTO 950
1040 PRINT "yes": GOTO 950
</script>
<script type="text/basicode">
1000 :
1010 FOR I = 0 TO 10 STEP 2.5
1020 PRINT I;
1030 NEXT I
</script>
<script type="text/basicode">
1000 GOSUB 100: PRINT "FOR test"
1010 I=2: FOR J=1 TO 2:FOR I = 0 TO 10 STEP 2.5
1020 PRINT I;
1030 PRINT I;J:NEXT I: PRINT I: NEXT J: PRINT J
</script>
<script type="text/basicode">
1000 GOTO 20: REM TEST
1010 PRINT "now";:INPUT A$: PRINT "you typed: "; A$; ", ";
1020 GOTO 1010
</script>
<script type="text/basicode">
1000 GOTO 20: REM TEST
1010 PRINT "\123456789\123456789\123456789\123456789";
1020 PRINT "\123456789\123456789\123456789\123456789"
</script>
<script type="text/basicode">
1000 GOTO 20: REM TEST
1010 DIMBE$(10):K=4:BE$(K)="abc"
1020 PRINTBE$(2*2)
</script>
<script type="text/basicode">
1000 GOTO 20: REM TEST
1010 INPUT "yes"; a$, b
1020 fori=1to1000:nexti:print "done"; tab(10); "done"; tab(5); "done"; a$;
</script>
<script type="text/basicode">
1000 GOTO 20: REM TEST
1010 PRINT 1.234E56
1015 IF 1 GOTO 1020
1020 PRINT 1.234E-56
1030 PRINT 1.234E+56
</script>
<script type="text/basicode">
1000 GOTO 20: REM TEST
1010 DEF FNA(X) = 1+X
1015 DEF FNB(Y)=2*Y
1020 X = 5: PRINT FNA(5); FNB(5); X
</script>
<script type="text/basicode">
1000 GOTO 20: REM TEST
1010 PRINT MID$("12345",2,2)
1020 PRINT MID$("12345",2)
1030 PRINT 0/0
</script>
<!-- // REM and GOTO test -->
<script type="text/basicode">
1000 A=2:REM test program
1010 GOTO 1030
1020 PRINT"this should not be visible"; A: REM ignore this
1030 GOTO 950
1040 PRINT "ignore me"
1050 :
30000 REM BASICODE test program:
30020 REM a program that tests REMs
</script>
<script type="text/basicode">
1000 A=2:REM test program 2
1010 B=5: GOSUB 10000
1020 B=6: GOSUB 10000
1025 B=7: GOSUB 10000
1030 B=7: GOTO 950
10000 PRINT B;
10010 RETURN
</script>
<script type="text/basicode">
1000 A=2:REM test program 3
1010 B=10: GOTO 1030: B=600
1020 B=1000
1030 PRINT B: GOTO 950
</script>
<script type="text/basicode">
1000 PRINT "if test":
1010 A=0: IF A THEN PRINT 1;
1020 PRINT 2;: IF NOT A THEN PRINT 3;
1030 PRINT 4: GOTO 950
</script>
<script type="text/basicode">
1000 :
1010 A=2: ON A GOTO 1020, 1030, 1040
1015 PRINT "None": GOTO 950
1020 PRINT 1020: GOTO 950
1030 PRINT 1030: GOTO 950
1040 PRINT 1040: GOTO 950
</script>
<script type="text/basicode">
1000 :
1010 A=3: ON A GOSUB 1020, 1030, 1040
1015 PRINT "back": GOTO 950
1020 PRINT 1020;: RETURN
1030 PRINT 1030;: RETURN
1040 PRINT 1040;: RETURN
</script>
<script type="text/basicode">
1000 :
1010 IF 0=0 THEN 1040
1020 PRINT "no": GOTO 950
1040 PRINT "yes": GOTO 950
</script>
<script type="text/basicode">
1000 :
1010 IF 0=0 THEN GOTO 1040: PRINT "certainly not"
1020 PRINT "no": GOTO 950
1040 PRINT "yes": GOTO 950
</script>
<script type="text/basicode">
1000 :
1010 FOR I = 0 TO 10 STEP 2.5
1020 PRINT I;
1030 NEXT I
</script>
<script type="text/basicode">
1000 GOSUB 100: PRINT "FOR test"
1010 I=2: FOR J=1 TO 2:FOR I = 0 TO 10 STEP 2.5
1020 PRINT I;
1030 PRINT I;J:NEXT I: PRINT I: NEXT J: PRINT J
</script>
<script type="text/basicode">
1000 :
1010 GOSUB 100: HO=10: VE=2: GOSUB 110: INPUT A$: PRINT "you typed: "; A$
1030 INPUT A: PRINT "value: "; A
1040 GOSUB 120: PRINT HO; VE;
1050 SR$="Testy": GOSUB 150
1060 HO=0: VE=3: GOSUB 220: SR$=IN$: GOSUB 150: PRINT IN
1070 GOTO 950
</script>
<!-- statement & expression tests -->
<script type="text/basicode">
1010 LET D=1:LET E=2
1020 IF E=2 THEN PRINT "pass" ELSE PRINT "FAIL"
1030 DIM C(20): C(1)=5
1040 IF C(1)=5 AND C(0)=0 THEN PRINT "pass" ELSE PRINT "FAIL"
1050 A$="1"
1060 IF A$="1" THEN PRINT "pass" ELSE PRINT "FAIL"
1070 IF (3+4*2)/5 = 2.2 THEN PRINT "pass" ELSE PRINT "FAIL"
2500 LET F=D+E
2520 IF F=3 THEN PRINT "pass" ELSE PRINT "FAIL"
3000 PRINT "print test: ";D;:print E-3;F:print f
3010 PRINT "TAB test: ";1;TAB(20);2;
4000 IF 1-2=-1 THEN PRINT "pass" ELSE PRINT "FAIL"
4010 IF .5=0.5 THEN PRINT "pass" ELSE PRINT "FAIL"
4020 IF -.5=-0.5 THEN PRINT "pass" ELSE PRINT "FAIL"
4030 IF 1.2e2=120 THEN PRINT "pass" ELSE PRINT "FAIL"
4040 IF 1.2e-2=0.012 THEN PRINT "pass" ELSE PRINT "FAIL"
5000 IF ((1=1)) OR (1=0) THEN PRINT "pass" ELSE PRINT "FAIL"
5010 IF NOT(((1=1)) AND (1=0)) THEN PRINT "pass" ELSE PRINT "FAIL"
5020 IF NOT 0 THEN PRINT "pass" ELSE PRINT "FAIL"
5030 IF 1 THEN PRINT "pass" ELSE PRINT "FAIL"
5040 IF -1 THEN PRINT "pass" ELSE PRINT "FAIL"
5050 IF COS(0)=1 THEN PRINT "pass" ELSE PRINT "FAIL"
5060 IF VAL("1e+2")=100 THEN PRINT "pass" ELSE PRINT "FAIL"
5070 IF VAL("1e-2")=0.01 THEN PRINT "pass" ELSE PRINT "FAIL"
</script>
<script type="text/basicode">
1010 READG,H,I, J
1020 PRINTJ
1030 :RESTORE: READ J: PRINT J
1035
1040 DATA67,68,69,70
1050 :
1060 PRINT"program done"
</script>
<script type="text/basicode">
1010 DIMZ(10)
1020 Z(9)=9
1030 PRINT Z(9)
</script>
</body>
</html>