A Computed GOSUB for Applesoft

How many times I have wished for one!  I guess I am spoiled from FORTRAN and Apple Integer BASIC.  The Computed GOTO is also left out, but I saw that one written up in a recent newsletter.  The author said he didn't know how to do the Computed GOSUB, so here it is!

<<<<listing>>>>

Lines 1160 and 1170 check the token after the "&" to see if it is "GOSUB"; if not, you will get a big SYNTAX ERROR.  Lines 1180 and 1190 check the stack to see if there is room for another GOSUB entry; if not, you get an OUT OF MEMORY error.  Lines 1200-1290 push the data on the stack that will be needed to RETURN.  Lines 1300 and 1310 compute the value of whatever expression follows the &GOSUB, and turn it into an integer that looks just like a line number.  Finally, lines 1320 and 1330 simulate a normal GOTO.  That's all there is to it!

Here is a sample Appplesoft program using the new &GOSUB statement:

 10 POKE 1013,76: POKE 1014,0: POKE 1015,3
 20 INPUT X
 30 &GOSUB x*100
 40 GOTO 20

100 PRINT 100:RETURN
200 PRINT 200:RETURN
300 PRINT 300:RETURN
400 PRINT 400:RETURN
