Add variable storage (scalar and array), program line storage with RUN/LIST/NEW, and full control flow: FOR/NEXT, GOTO, GOSUB/RETURN, IF/THEN/ELSE, WHILE/WEND, ON GOTO/GOSUB, DATA/READ/RESTORE. New modules: interp.c (1445 lines - execution loop and statement dispatcher), vars.c, arrays.c, input.c. Version bumped to 0.2.0. 16 test programs pass including Leibniz pi and prime sieve.
16 lines
327 B
QBasic
16 lines
327 B
QBasic
10 REM GOSUB/RETURN test
|
|
20 PRINT "Main program"
|
|
30 GOSUB 100
|
|
40 PRINT "Back from first sub"
|
|
50 GOSUB 200
|
|
60 PRINT "Back from second sub"
|
|
70 END
|
|
100 REM First subroutine
|
|
110 PRINT "In first subroutine"
|
|
120 GOSUB 200
|
|
130 PRINT "Back in first sub"
|
|
140 RETURN
|
|
200 REM Second subroutine
|
|
210 PRINT "In second subroutine"
|
|
220 RETURN
|