Contents / Reference section / Previous chapter / Next chapter / Index
There are a number of ways of merging two BASIC programs together. Two are given below. In either case the line numbers should not clash unintentionally.
In order to correctly merge two programs together it is necessary to save one of them (the shorter one preferably), as an ASCII file rather than in the usual compressed format. This ASCII version of the program is then merged into the longer program using the command *EXEC. Suppose we wish to merge the program SHORT into the program LONG. First, load in the first program
and then create an ASCII version by typing in the next three lines
This produces an ASCII version of the program. The ASCII version is called SHORT2
Now load in the big program by typing
This loads the long program
and lastly merge in the small program
This merges the short program
informs the computer that anything that it outputs to the screen is also to be sent to a cassette (or disc, etc.), file called SHORT2. When the computer lists the file it therefore creates an ASCII listing on cassette. The command *SPOOL without a filename is used to end or close the spooled file.
Having created the ASCII version of SHORT called SHORT2, the user then loads the file LONG. The command *EXEC "SHORT2" tells the computer to read in the file SHORT2 as if it were getting characters from the keyboard. If the file SHORT2 contains line numbers (as it does), then these lines will just be added to the BASIC program. Of course, a line number read in from SHORT2 will replace any line with an identical line number in LONG, so it is normal to renumber the two programs SHORT and LONG so that the line-numbers don't clash.
A rather quicker (and "dirtier") method is given below - but if you use this method you must make sure that the second program that you loaded in uses larger line numbers than the first program. You will get predictable but surprising results if not.
Firstly load the program (with the lower line numbers) in the normal way. Then get the computer to print, in hex, the topofprogram address less 2 by entering
Call the resultant number XXXX. Then enter
*LOAD SHORT XXXX
to load the program SHORT (or whatever you have called it) in above the first program. Finally type END to get the computer to sort its internal pointers out. A typical dialogue might look like this - assuming that one program is called ONE and the other is called TWO.
>*LOAD TWO 195F
This method is very easy but you must look after the line numbers.