1000 REMark quicksort all lines in a file. 1010 : 1020 REMark $$stak=100000 1030 screen 290,96 1040 banner 290,' Filesort ' 1050 count=0 1060 INPUT#3;'File >';inp$ 1070 IF inp$='':STOP 1080 OPEN#5,inp$ 1090 count=0 1100 REPeat l 1110 IF EOF(#5):EXIT l 1120 INPUT#5,temp$ 1130 inc count 1140 END REPeat l 1150 BGET#5\0 1160 DIM a$(count,46) 1170 FOR f=1 TO count:INPUT#5,a$(f) 1180 PRINT#3;'** SORTING ** ';count;' elements....' 1190 start=DATE 1200 qsort a$,1,count 1210 fin=DATE 1220 PRINT#3;'Sorting took ';fin-start;' seconds.' 1230 BGET#5\0 1240 FOR f=1 TO count:PRINT#5,a$(f) 1250 CLOSE#5 1260 INPUT#3,'Press ENTER to quit',i$ 1270 : 1280 DEFine PROCedure inc(n) 1290 REMark increase the actual parameter by one 1300 n=n+1 1310 END DEFine inc 1320 : 1330 DEFine PROCedure screen(wide,high) 1340 REMark standard screen setup 1350 REMark channel 4 as banner and border, channel 3 as output channel 1360 REMark centered on screen 1370 LOCal x,y 1380 OPEN#4,'con_2x1a0x0' 1390 x=(512-wide)/2 1400 y=(256-high)/2 1410 WINDOW#4,wide,high,x,y 1420 BORDER#4,1,0:PAPER#4,7,4,1:INK#4,0:CLS#4 1430 OPEN#3,'con_2x1a0x0' 1440 WINDOW#3,wide-4,high-12,x+2,y+11 1450 PAPER#3,7:BORDER#3,1,4:INK#3,0:CLS#3 1460 END DEFine screen 1470 : 1480 DEFine PROCedure banner(wide,banner$) 1490 REMark print centered text in the banner produced by Screen or Command_Screen 1500 AT#4,0,0:CLS#4,3 1510 STRIP#4,7:AT#4,0,(INT(wide/6)-LEN(banner$))/2:PRINT#4;banner$ 1520 STRIP#4,7,4,1 1530 END DEFine banner 1540 : 1550 DEFine PROCedure qsort(array,bottom,top) 1560 LOCal loop,lo,hi,pointer,temp$ 1570 lo=bottom:hi=top 1580 pointer=bottom 1590 REPeat loop 1600 IF lo>=hi:EXIT loop 1610 IF array(lo)>array(hi) 1620 temp$=array(lo) 1630 array(lo)=array(hi) 1640 array(hi)=temp$ 1650 IF pointer=lo 1660 lo=lo+1:pointer=hi 1670 ELSE 1680 hi=hi-1:pointer=lo 1690 END IF 1700 ELSE 1710 IF pointer=lo 1720 hi=hi-1 1730 ELSE 1740 lo=lo+1 1750 END IF 1760 END IF 1770 END REPeat loop 1780 IF ABS(top-bottom)<2 THEN RETurn 1790 qsort array,bottom,pointer-1 1800 qsort array,pointer+1,top 1810 END DEFine qsort