On the Apple ][, in AppleSoft BASIC, you can set what the start address
of your BASIC program will be in memory by poking it into location 103-104
($68-$69 hex).
The only problem here of course is that any variables in either program
will be quashed when the alternate program is run. However, there are
also pointers that point to the beginning of variable memory, and I'm sure
there would be a way to preserve these pointers so that individual
variables for either program stay intact between transitions. Something
worth exploring just for the hack value.
I wrote something like this to switch between two BASIC programs using the
& command back around '83-'84. I think the key was to also set the himem
pointer (the highest location available to basic variables) along with the
lomem pointer. In that case each program gets separate variable memory.
I remember trying to cooperatively multitask running programs by saving
and restoring some other zero page locations. I think there's a pointer to
the next basic token when running and some other state information.
I'd need to look at a zero page map. I had some parital sucess but I don't
think I ever got it fully working. It should be possible, though.
Maybe I should pull out my GS and see if I can resurect the code. Far too
many of my floppies from that era are unreadable though. I went through a
"dark decade" without a ][ compatible to remaster them on. :(
It seems to me this could be mutated into a sort of
practical method of
multi-tasking BASIC programs.
It's fun for the hack value. The program switcher was useful as it basically
allowed running another program without blitzing the code you were working on.
Kind of a BASIC TSR.
Eric