10 'PATCHER - file patching program - PROGRAMMERS JOURNAL Vol 1, No 6, Pg. 21 20 'Copyright 1983 - Data Base Decisions, Atlanta, GA 30 'This program is used to patch other programs or files. It requires 40 'a data file containing the patches. The first three items in the 50 'patch file are the name of the file to be patched, a check sum, and 60 'comments. For each byte to be patched, there is one record containing 70 'the offset of the byte to be patched, the old value of the byte, 80 'and the new (patch) value. 90 'Patches are generated using program GENPATCH.BAS 100 'Note: If the offset is greater than 32,767, BASIC 2.00 must be used. 110 CLS 120 DEFINT A-Z 130 CLEAR 140 ON ERROR GOTO 500 150 CLOSE 160 PRINT : INPUT "Name of file containing patches";PAT$ 170 IF PAT$="" THEN END 180 OPEN "i",#1,PAT$ 190 INPUT #1,FIL$,CKSUM!,COMMENT$ 200 OPEN "i",#2,FIL$ 'is it there 210 PRINT "Patching: " FIL$ 220 PRINT "Comments: " COMMENT$ 230 CLOSE 2 240 OPEN "r",#2,FIL$,1 'reopen as random file 250 FIELD 2,1 AS R$ 260 FILE.LEN = LOF(2) 270 IF EOF(1) THEN 450 280 INPUT# 1,BYTE!,OLDVAL,NEWVAL 'get patch 290 NEWSUM!=(NEWSUM!+BYTE!+OLDVAL!+NEWVAL!) 300 PRINT BYTE!,OLDVAL,NEWVAL, "Checksum " NEWSUM! 310 IF NEWSUM! > 32767 THEN NEWSUM!=NEWSUM!-32767: GOTO 310 320 IF BYTE! > FILE.LEN THEN PRINT "Byte " BYTE! " is beyond end of file": GOTO 330 GET 2,BYTE! 340 R=ASC(R$) 350 IF R <> OLDVAL THEN PRINT "Old value for byte " BYTE! " is " R " not " OLDV 360 LSET R$=CHR$(NEWVAL) 370 PUT 2,BYTE! 380 APPLIED=APPLIED+1 390 GOTO 270 400 REM *** invalid condition *** 410 BEEP:INPUT "Continue (y/n)";ANS$ 420 IF ANS$="Y" OR ANS$="y" THEN 390 430 IF ANS$="N" OR ANS$="n" THEN 450 440 GOTO 400 450 REM *** wrap it up *** 460 IF CKSUM!=NEWSUM! THEN PRINT "Checksums match" ELSE PRINT "Checksums do not 470 PRINT "Patches applied: " APPLIED 480 CLOSE 490 END 500 REM *** error handler *** 510 UNABLE$="Unable to " 520 IF ERL=180 OR ERL=280 THEN PRINT UNABLE$ "read " PAT$ 530 IF ERL=200 OR ERL=240 OR ERL=330 THEN PRINT UNABLE$ "read " FIL$ 540 IF ERL=370 THEN PRINT UNABLE$ "write " FIL$ 550 RESUME 120 è¬îÃé vévÇE