1000 REMark program to scan all files in a tree and calculate checksum, printing 1010 REMark result to a file, then quicksort the file. Allows easy verification 1020 REMark of a disc backup. 1030 : 1040 REMark $$stak=100000 1050 screen 290,96 1060 banner 290,' Checksums ' 1070 count=0 1080 INPUT#3;'Scan tree from >';drv$ 1090 if drv$='':stop 1100 INPUT#3;'Output file >';out$ 1110 if out$='':stop 1120 OPEN_NEW#5,out$ 1130 scan_tree drv$ 1140 CLOSE#5 1150 OPEN_IN#5,out$ 1160 DIM a$(count,46) 1170 FOR f=1 TO count 1180 INPUT#5;a$(f) 1190 END FOR f 1200 CLOSE#5 1210 PRINT#3;'** SORTING ** ';count;' elements....' 1220 start=DATE 1230 qsort a$,1,count 1240 fin=DATE 1250 PRINT#3;'Sorting took ';fin-start;' seconds.' 1260 OPEN#5,out$ 1270 for f=1 to count:PRINT#5,a$(f) 1280 CLOSE#5 1290 INPUT#3,'Press ENTER to quit';dummy$ 1300 : 1310 DEFine PROCedure scan_tree(level$) 1320 LOCal loop,chan,f,char,temp$(64),temp 1330 chan=FOP_DIR(level$) 1340 DIM temp$(64) 1350 temp$=FILL$(' ',64) 1360 REPeat loop 1370 IF EOF(#chan):EXIT loop 1380 FOR f=1 TO 64 1390 temp$(f)=INKEY$(#chan,100) 1400 END FOR f 1410 IF temp$(6)=CHR$(255) 1420 REMark if we got a directory... 1430 temp=(256*CODE(temp$(15)))+CODE(temp$(16)) 1440 scan_tree drv$(1 TO 5)&temp$(17 TO 16+temp) 1450 ELSE 1460 REMark we got a file 1470 file_found temp$ 1480 END IF 1490 END REPeat loop 1500 CLOSE#chan 1510 END DEFine scan_tree 1520 : 1530 DEFine PROCedure file_found(header$) 1540 LOCal temp,file_name$,temp$ 1550 temp=(256*CODE(header$(15)))+CODE(header$(16)) 1560 IF temp>0 1570 file_name$=header$(17 TO 16+temp) 1580 temp$=file_name$&FILL$(' ',38) 1590 temp$=temp$(1 TO 38)&csum$(file_name$) 1600 upper temp$ 1610 PRINT#3,temp$ 1620 PRINT#5,temp$ 1630 inc count 1640 END IF 1650 END DEFine file_found 1660 : 1670 DEFine FuNction csum$(file_name$) 1680 LOCal sz,base,temp 1690 sz=FLEN(\drv$(1 TO 5)&file_name$) 1700 base=ALCHP(sz) 1710 IF base=0:RETurn ' **** ' 1720 LBYTES drv$(1 TO 5)&file_name$,base 1730 temp=FCHECK(base,base+sz) 1740 RECHP base 1750 RETurn HEX$(temp,32) 1760 END DEFine csum$ 1770 : 1780 DEFine PROCedure inc(n) 1790 REMark increase the actual parameter by one 1800 n=n+1 1810 END DEFine inc 1820 : 1830 DEFine PROCedure Dec(n) 1840 REMark decrease the actual parameter by one 1850 n=n-1 1860 END DEFine Dec 1870 : 1880 DEFine PROCedure screen(wide,high) 1890 REMark standard screen setup 1900 REMark channel 4 as banner and border, channel 3 as output channel 1910 REMark centered on screen 1920 LOCal x,y 1930 OPEN#4,'con_2x1a0x0' 1940 x=(512-wide)/2 1950 y=(256-high)/2 1960 WINDOW#4,wide,high,x,y 1970 BORDER#4,1,0:PAPER#4,7,4,1:INK#4,0:CLS#4 1980 OPEN#3,'con_2x1a0x0' 1990 WINDOW#3,wide-4,high-12,x+2,y+11 2000 PAPER#3,7:BORDER#3,1,4:INK#3,0:CLS#3 2010 END DEFine screen 2020 : 2030 DEFine PROCedure banner(wide,banner$) 2040 REMark print centered text in the banner produced by Screen or Command_Screen 2050 AT#4,0,0:CLS#4,3 2060 STRIP#4,7:AT#4,0,(INT(wide/6)-LEN(banner$))/2:PRINT#4;banner$ 2070 STRIP#4,7,4,1 2080 END DEFine banner 2090 : 2100 DEFine PROCedure qsort(array,bottom,top) 2110 LOCal loop,lo,hi,pointer,temp$ 2120 lo=bottom:hi=top 2130 pointer=bottom 2140 REPeat loop 2150 IF lo>=hi:EXIT loop 2160 IF array(lo)>array(hi) 2170 temp$=array(lo) 2180 array(lo)=array(hi) 2190 array(hi)=temp$ 2200 IF pointer=lo 2210 lo=lo+1:pointer=hi 2220 ELSE 2230 hi=hi-1:pointer=lo 2240 END IF 2250 ELSE 2260 IF pointer=lo 2270 hi=hi-1 2280 ELSE 2290 lo=lo+1 2300 END IF 2310 END IF 2320 END REPeat loop 2330 IF ABS(top-bottom)<2 THEN RETurn 2340 qsort array,bottom,pointer-1 2350 qsort array,pointer+1,top 2360 END DEFine qsort