8-Bit Software Online Conversion

Merging programs by D. Ambrose I wrote a program to serve my needs as Treasurer of a society and it appeared in Beebug Vol.9 no.9 p.10. In this program I keep details of the members of my society as DATA and deal with them by the Basic READ command. There are too many DATA be in memory at the same time so I enter them in three separate blocks. Originally these DATA blocks were appended to the program from disc one after the other by means of the function keys but the method was clumsy, and in use the program got tangled up very easily. The procedures described now and illustrated in the program MERGE are more elegant and more robust. MERGE is the result of exploration in early issues of Acorn User where I found articles on overlays (November 1982, p.67) and program merging (October 1983, p.66). From the first I arrived at PROCovly. From the second I arrived at PROCjoin which suits me now because I have installed the 65C102 co-processor in my Master and have room to load all three of my DATA blocks at the same time - but it is still convenient to keep the DATA in separate files that are small enough to fit in EDIT. Having got so far the question arose whether the two Procedures could each perform the function for which I had developed the other, and of course they can. The two Procedures with their two different routes to the operating system (PROCovly using OSCLI, PROCjoin using OSFILE) perform identical functions if they start with the correct address for loading. PROCjoin moves TOP (T%), so T% must be pulled back to its original value C% if it is to overlay, whereas with PROCovly the address must be moved on by FNend if it is to append. An alternative to FNend is to determine the length of the file on disc by the following - Z%=OPENUP f$ L%=EXT#Z% CLOSE#Z% T%=T%+L%-2. The program shows the operation of both Procedures in both modes. Although my need is to load blocks of DATA (here in D1, D2, D3, D4), the Procedures are equally applicable for loading program elements, which may either be overlaid, or appended to the accumulated program. To illustrate this I have arranged for OVLY (containing PROCovly) to be brought from disc by PROCjoin. What is going on will be invisible when the program is run and it is probably necessary to interrupt it by pressing ESCAPE at suitable points during the RUN to understand it fully. When overlays are used, room for them must be made by increasing LOMEM. The value I have used is arbitrary but it will be necessary to investigate how much room is needed for operation of the program and to adjust the size of the overlays accordingly if the program and overlays are more than the trivialities of my example. RESTORE must be used each time a new DATA block is loaded since the program would otherwise be trying to READ beyond the end of the DATA in the preceding block. Details of OSCLI and OSFILE will be found on pages D.4-1 and H.3-6 respectively of Part 1 of the Master Reference Manual. The Manual prescribes that for OSFILE the file name must end with carriage return (line 1020) but this appears to be unnecessary.