Login
Back to forumReply to this topicGo to last reply

Posted By

George
on 2019-06-19
17:58:53
 Load a BASIC Program from a BASIC Programm

Hi,
Does anybody know if it is possible to load a Basic Program from a Basic Programm?
I want to chain two programms:
Programm A-> Program B
Greetings George

Posted By

Spektro
on 2019-06-19
19:48:53
 Re: Load a BASIC Program from a BASIC Programm

Hi George,
Yes, it's possible. Here is an example:

Save the following program as "TEST1":

10 PRINT"HELLO"
20 DLOAD"TEST2"


Save the following program as "TEST2":

10 PRINT"WORLD"


Load the first program (TEST1) and run it. The first program will print "HELLO" and then loads the second program (TEST2). Once the second program has been loaded, it will be run automatically and thus it will print "WORLD". If you have additional lines in TEST1 after the line 20, those lines will never be executed.

Posted By

SVS
on 2019-06-20
02:02:37
 Re: Load a BASIC Program from a BASIC Programm

Caution, if the second program is larger than the program in memory, you have to manually fix the variables BASIC pointers at:
$2D/2E: End of program +1
$2F/30: End of variables +1
$31/32: End of arrays +1
In this way you can keep the variables created by the first program. If you don't, the variables pointers do remain the same and will corrupt the code of the second program.

Posted By

George
on 2019-06-20
02:10:56
 Re: Load a BASIC Program from a BASIC Programm

@Spektro Thank you. I tried this but have the effect SVS describes.
@Svs Thats the effect i have. 2 prg is larger. Is there an example around how to fix the pointers?

Posted By

SVS
on 2019-06-20
05:59:45
 Re: Load a BASIC Program from a BASIC Programm

You can retrieve the end-address of the program in this way:
- load the larger program;
- Peek($9D), Peek($9E) to obtain the end-address+1 to POKE inside the address' I've specified.

If you do the POKEs by the first program (in its first statements) you can maintain the variables between one prg to another.

Posted By

MikeZ
on 2019-06-20
07:17:19
 Re: Load a BASIC Program from a BASIC Programm

Nicely done SVS!

Posted By

George
on 2019-06-20
07:25:01
 Re: Load a BASIC Program from a BASIC Programm

Thanks SVS!

I decided not to use it. I kept the programm separated.
This is a good topic for the knowledge base.

Greetings
George

Posted By

GeTE
on 2019-06-21
09:01:58
 Re: Load a BASIC Program from a BASIC Programm

I used to use it often in my very old and first programs. You only had to write the commands on screen, fill the keybuffer with returns, set the cursor on top of the screen and stop your BASIC-program with end.

Take a look at the first part of this old crap of mine and you see what I meant: Osterei-Sucherei



Back to topReply to this topic


Copyright © Plus/4 World Team, 2001-2024. Support Plus/4 World on Patreon