117. Comparing programs with memory ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This is a routine along the same lines as the previous one, but is for comparing a purely BASIC program in memory with a named program on disc. (It does not work with cassette.) BASIC in this context also included programs containing assembler code. Since it is for comparing a program in memory with one on disc, the routine cannot conveniently be in the the form of a program itself. So, it is stored on a red function key ready for calling at any time. Before programming the key, (I have used *KEY0 in this example), you should type *FX18 to clear all the keys, as the routine takes up most of the available space on a B/B+. The key definition can be saved on a B/B+ with *SAVE name FFFF0B00+100, and reloaded at any time with *LOAD name . On a Master/Compact, save the definition as a one-line program, and simply CHAIN it to redefine the key when required. The routine is compatible with the 6502 2nd processor. When called, the routine first prints out the length of the program in memory, and then prompts for a filename. This will repeat until a valid filename is found, and then the length of the disc file is also printed before a byte-for-byte check is carried out. There is a similar routine in BEEBUG, but it doesn't check for different lengths before laboriously comparing byte-for-byte, and with BASIC-I it is liable to try and lengthen the file if it is shorter than the program in memory! Note that in order to squeeze everything on to one key definition, I have had to use many abbreviations, and only vital spaces have been retained. I have split the lines at convenient colons, but the definition is actually typed in as one continuous line. It may help to omit the first term VDU21|M initially, otherwise it tends to suppress any syntax error messages if you make a typing mistake. When the routine is debugged, you can restore the first term to give a neater effect on the screen. *K.0VDU21|MCLO.#0:P." Length : &";~TOP-PA.:REP.I."Filename : "f$: ch=OP.f$:U.ch:P." Length : &";~EXT#ch:M%=-1: REP.M%=M%+1:U.EXT#ch<>TOP-PA. ORBGET#ch<>M%?PA. OR EOF#ch: IF EOF#ch TH.P."Identical"ELSEP."Different":CLO.#0|F|M