BASIC 7.0 Program Chaining

Started by Stephane Richard, October 03, 2006, 01:23 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Stephane Richard

Well by that I mean the following scenario:

1. I have a main menu program that would present different options.
2. each of these options would bring up a different program in memory.  
3. when I exit the selected program I would like it to go back to the main menu program.


how easy is that to do in BASIC 7 ?

can I simply do something like

when a is selected I do a dload "program name": run

and at the end of that program I dload "main": run

is that possible?  is there a better way to do this?

Thanks all :-).
When God created light, so too was born, the first Shadow!

MystikShadows

xlar54

Well, it can be done as you suggested, but theres a few things you need to know...

Dont use RUN... it will wipe out your original program by resetting important pointers.  What I did with the BBS we've been talking about it write an ML routine to load in the new code at the end of the main program, and relink the program. (relinking is how the BASIC interpreter finds the next program line in the code...basically a linked list) The C128 puts variables in a different bank of memory, so variables will be ok. Look for the bbs code I uploaded in a different post. It has all the ml and example code of how to use it.

Stephane Richard

xlar, you rock man :-).  what you're saying makes perfect sense. and yeah, i'll be getting that bbs example.

thank you, i really appreciate the help in unrusting my brains :-).

EDIT: I found the sample code from the sourceforge website, great work, it works great in winvice too.
When God created light, so too was born, the first Shadow!

MystikShadows

xlar54

Ive always been into the program chaining/ linking... when I first saw CNet 64 BBS do that back in the 80s, I was really intrigued... The 128 makes it even better by not storing variables in BASIC space.  On the 64, you essentially go through the same process,  but you have to relocate the variables. Mind you, Im really an amatuer at ML on the 128 - Im sure a real guru would tear my code apart ;)  (Id love to see the ML for the BBS be slimmed down considerably...Ive been coding in higher level languages too long to think "efficient" :) )  But thanks for the kind words, hope it helps you!

BigDumbDinosaur

Quote from: Stephane Richard on October 03, 2006, 01:23 AM
Well by that I mean the following scenario:

1. I have a main menu program that would present different options.
2. each of these options would bring up a different program in memory.   
3. when I exit the selected program I would like it to go back to the main menu program.


how easy is that to do in BASIC 7 ?

can I simply do something like

when a is selected I do a dload "program name": run

and at the end of that program I dload "main": run

is that possible?  is there a better way to do this?

Thanks all :-).

Somehow I stumbled across this post and even though it's a bit stale, I thought I'd reply anyhow.

In BASIC 7.0, you can non-destructively chain programs by the simple expedient of LOAD "PROGRAM",DN (DN being the device number).  <Grin>  No special gyrations are necessary, no variables will be harmed, etc.  This works because following a LOAD, BASIC always resets its CHRGET pointers, which causes a start at the beginning.  So, LOAD your program and when it's done and it's time to go back to your menu, just LOAD the menu.  No RUN is needed.
x86?  We ain't got no x86.  We don't need no stinking x86!