Chapter 28. Merging BASIC Programs

Two methods are given here by which you can merge two BASIC programs which are stored on cassette, and in future expansions, disc as well.

(i) This method requires you to LOAD one of the programs (preferably the shorter) and then to re-save it as an ASCII file using *SPOOL. You can then LOAD the other program; and the spooled program will be entered as the equivalent of keyboard input by loading it using *EXEC. Assuming that the two programs are called LARGE and SMALL, the procedure is as follows:

LOAD "SMALL"

Now set the tape recorder to a blank section of tape.

*SPOOL "SMALL"
LIST
*SPOOL

The program SMALL is now saved as an ASCII text file.

LOAD"LONG"
*EXEC "SMALL"

The merger is now complete. Any line numbers in LARGE that coincide with those in SMALL will be overwritten. If you want to add SMALL to the end of LARGE then you have to adjust the line numbers before SMALL is spooled. When you use *SPOOL, anything that is output to the screen is also sent to the cassette. That is why you must type LIST. *SPOOL without the file name closes the file that has been spooled.

(ii) This is a slightly simpler method, but the line numbers of SMALL must be adjusted so as all to be higher than the highest line number in LARGE. The idea is to LOAD the program with the lower line numbers, and *LOAD the program with higher numbers at TOP-2. Lastly, it is necessary to type END so that the computer can trace the lengthened program.

The procedure is:

LOAD"LARGE"
OSCLI"LOAD""SMALL""" + STR$~(TOP-2)

This method is very easy, but you must be careful to adjust the line numbers.