116. Comparing disc files (B/B+/Master) ~~~~~~~~~~~~~~~~~~~~ It is useful if you can compare different files to see if any of them are the same. I often seem to end up with different versions of a program or file on different discs, but under the same filename. At other times, I find the exact same program saved under two different names. It can help to use *INFO, but this will only tell you whether or not the files are of the same length. This short program will compare any two named files, whether BASIC, machine-code, text files etc., and check that they are of the same length, and that they are byte-for-byte identical. The first filename prompt will repeat until a valid filename is found on the appropriate disc, and then the second filename prompt is repeated until a valid but different filename is found. Obviously, the two filenames must be different, and they can be different in actual name, directory, or in drive. If you have two drives, then the two names might be "FRED" and ":1.FRED". If the two files are both on the same disc, then the names might be "FRED" and "A.FRED", or "FRED" and "FRED1", or "FRED" and "JOE". If a filename prompt keeps reappearing after you type a name in, then either that filename cannot be found on the disc, or else you are are typing in two identical filenames. The routine is compatible with the 6502 2nd processor. The length of the file is displayed in Hex after each filename is entered. If the two files are not of the same length, then the program only takes a few seconds to run, otherwise it may take quite a bit longer if the files are large ones, and if any differences are not found until near the end of the files, if at all. Many of the spaces in the listing, but by no means all, can be omitted. If in doubt, type them all in at first. Note that there is a tilde in lines 130 and 160, looking like "~", and this is easily overlooked. 100 CLOSE#0:same=FALSE:ON ERROR GOTO 230 110 REPEAT:INPUT "1st Filename : " file1$ 120 ch1=OPENUP(file1$):UNTIL ch1>0 130 PRINT TAB(6) "Length : &";~EXT#ch1 140 REPEAT:INPUT "2nd Filename : " file2$ 150 ch2=OPENUP(file2$):UNTIL ch2>0 160 PRINT TAB(6) "Length : &";~EXT#ch2 170 IF EXT#ch1<>EXT#ch2 THEN 200 180 REPEAT UNTIL BGET#ch1<>BGET#ch2 OR EOF#ch1 190 IF EOF#ch1 THEN same=TRUE 200 PRINT "These files are "; 210 IF same THEN PRINT "identical" ELSE PRINT "different" 220 PRINT:CLOSE#0:END 230 IF ERR=194 THEN 140 ELSE CLOSE#0:REPORT:PRINT " at line ";ERL NB: I have also written a version for BASIC programs only, which actually checks line-by-line, and tells you the line number(s) where the first difference is found. The difference may be in the contents of the line, or the actual line numbers themselves. It is too long to print here, but is available as two UUcode files entitled "BASIC COMPARE UTILITY"