This doesn't necessarily bear on the question, but Magic GOTO/GOSUB doesn't rely on error trapping, rather it makes use of the fact that GOSUB "SOMETHING" is evaluated by Applesoft/MS BASIC as GOSUB 0, and the handler is on line 0. It doesn't raise an error though.
-Paul > On Nov 16, 2018, at 1:11 PM, John R. Hogerhuis <[email protected]> wrote: > > Not that I know of. There might be a hook to modify the behavior of gosub > with machine language code. > > -- John. > > On Fri, Nov 16, 2018, 8:53 AM Scott Lawrence <[email protected] wrote: > Do any of you know of a T version of "Magic Goto"? > > http://ivanx.com/appleii/magicgoto/ > > It basically uses an error trap to catch bad gotos (as the basic interpreter > sees them) and then looks for the label from the error handler, and uses > that... mainly using REM statements to define the labels. > > I'm thinking it might be possible to accomplish a similar thing on the Ts > using ON ERROR GOTO, perhaps peeking back into the return location and > getting the label name there. > > ie: (pseudoish code) > > 10 ON ERROR GOTO 1000 > ... > 20 GOSUB "InitCode" > 30 GOSUB "DoStuff" > 40 END > > 100 REM InitCode > 110 PRINT "hello 1" > 120 RETURN > 200 REM DoStuff > 210 PRINT "hello 2" > 220 RETURN > > 1000 ... figure out the label, resolve it to a line number then goto there... > > (and apologies if all of you have advanced far past BASIC on the Ts, and are > like writing pascal or whatever... although a micropython or lua would be > neat... or at least structured basic without line numbers... I forgot how > much I miss that from AmigaBASIC...) > > -s > -- > Scott Lawrence > [email protected]
