1 '                 DISKCAT SORT/PRINT PROGRAM
2 '      (C) COPYRIGHT 1983 NELSON FORD  ALL RIGHTS RESERVED
3 '
10 SCREEN 0,1: WIDTH 80
20 DEFINT A-Z:	DIM F$: F$=":diskcat.dta"
23 BG=0: IF (PEEK(&H410) AND &H30)<>&H30 THEN FG=6 ELSE FG=7
24 COLOR FG, BG, BG
30 DIM X, X$, JOB, D$(2), Y$, I, N$(2,2000), LAST(2), STACK(20), N(2,2000)
40 CLS: PRINT TAB(30) "D I S K C A T":  LOCATE 5,1,0:  X=20
50 PRINT TAB(X) "1  Compare two DISKCAT.DTA files"
60 PRINT TAB(X) "2  Print DISKCAT.DTA sorted by file name"
65 PRINT TAB(X) "3  Print DISKCAT.DTA sorted by disk name"
70 PRINT TAB(X) "4  Print DISKCAT.DTA sorted by file type"
80 PRINT TAB(X) "5  Print DISKCAT.DTA sorted by file extension"
90 PRINT TAB(X) "6  Return to main program"
95 PRINT TAB(X) "7  Return to DOS": PRINT
100 PRINT TAB(X) "   Select";
110 LOCATE,X: GOSUB 150
120 IF X$<"1" OR X$>"7" THEN 110  ELSE JOB= VAL(X$)
130 ON JOB GOTO 1000,2000,2000,2000,2000,131,135
131 '
132 PRINT:PRINT:PRINT TAB(X) "What drive is DISKCAT on?  ";: GOSUB 150
133 X$=X$+":diskcat":  CHAIN X$
134 '
135 END
139 '
140 ''''''''''get keypress:
141 '
150 COLOR 16,FG: PRINT CHR$(219) CHR$(29);: COLOR FG,BG
160 X$=INKEY$: IF X$="" THEN 160 ELSE PRINT X$;
170 IF X$=CHR$(27) THEN RUN
171 IF X$=CHR$(3) THEN END ELSE RETURN
180 '
190 ''''''''''sort:
191 '
200 CLS: LOCATE 12,35: PRINT "SORTING": TOP=0 : LO=1 : HI=LAST(S)
210   WHILE 1
220	WHILE LO < HI
230 IF HI-LO >1 THEN GOTO 260
240 IF N$(S,LO)<=N$(S,HI) THEN 320
250 SWAP N$(S,LO),N$(S,HI): SWAP N(S,LO),N(S,HI)
260 J=HI+1: GOSUB 350
270 IF J-LO >= HI-J THEN GOTO 290
280 STACK(TOP+1)=J+1: STACK(TOP+2)=HI:	 HI=J-1 : GOTO 300
290 STACK(TOP+1)=LO:  STACK(TOP+2)=J-1:  LO=J+1
300 TOP=TOP+2
310	WEND
320 IF TOP=0 THEN RETURN
330 HI=STACK(TOP) : LO=STACK(TOP-1) : TOP=TOP-2
340   WEND
350 '
360 CK.PT$= N$(S,LO) : I=LO
370   WHILE 1
380 I=I+1 : IF N$(S,I) < CK.PT$ AND I CK.PT$ THEN GOTO 390
400 IF I"\" AND T$<>" " THEN J=J+1: N$(S,J)=X$: N(S,J)=J: GOTO 1060
1070 CLOSE:  LAST(S)= J:  GOSUB 200  'go sort
1080	NEXT
1090 'print comparison:
1100 I=1:  J=1:  L=1:  CLS:  CLOSE
1110 LOCATE 12,5: PRINT"Print comparative lists to [1] Screen or [2] Printer? ";
1120 GOSUB 150
1130 IF X$="1" THEN O$="scrn:" ELSE IF X$="2" THEN O$="lpt1:": GOSUB 1250            ELSE 1120
1140 OPEN O$ FOR OUTPUT AS #1:	CLS
1142 OPEN D$(1)+F$ AS 2 LEN=74
1143 FIELD 2, 12 AS NM$, 8 AS DSK$, 35 AS Y$, 10 AS DT$, 7 AS SZ$, 2 AS Y$
1144 FIELD 2, 1 AS T$, 73 AS Y$
1145 OPEN D$(2)+F$ AS 3 LEN=74
1146 FIELD 3, 12 AS NM2$, 8 AS DSK2$, 35 AS Y$, 10 AS DT2$, 7 AS SZ2$, 2 AS Y$
1147 FIELD 3, 1 AS T2$, 73 AS Y$
1150 GET 2, N(1,I):  GET 3, N(2,J)
1151 IF NM$<>NM2$ OR SZ$<>SZ2$ THEN 1160
1152 PRINT #1, NM$"  "SZ$"  "DSK$ TAB(40) NM2$"  "SZ2$"  "DSK2$:  I=I+1: J=J+1:      GOTO 1165
1160 IF NM$<=NM2$ THEN PRINT #1, NM$"  "SZ$"  "DSK$: I=I+1: GOTO 1170                ELSE  PRINT TAB(40) NM2$"  "SZ$"  "DSK$: J=J+1: GOTO 1170
1165 Q$=INKEY$: IF Q$="" THEN 1170 ELSE L=CSRLIN
1166 LOCATE 25,3: PRINT"1-Continue  2-Start printing over  3-Start program over  4-End  ";: GOSUB 150:  IF X$="1" THEN LOCATE L,1: GOTO 1170
1167 IF X$="2" THEN 1100  ELSE IF X$="3" THEN RUN
1169 IF X$="4" THEN END ELSE 1166
1170 L=L+1: IF O$="lpt1:"  THEN 1210
1180 IF L<=20 THEN 1200 ELSE PRINT: PRINT "Press Enter to continue."
1190 GOSUB 150: L=1: CLS
1200 GOTO 1230
1210 IF L<=50 THEN 1230
1220 LPRINT CHR$(12): GOSUB 1260: L=1
1230 IF I="\" AND T$<>" " THEN IF T$<>"z" THEN J=J+1: N$(1,J)=X$+W$: N(1,J)=I:     GOTO 2070 ELSE 2070
2080 LAST(1)= J
2090 S=1: GOSUB 200
2400 CLS: CLOSE: LOCATE 10
2410 PRINT TAB(30) "1  To printer"
2420 PRINT TAB(30) "2  To screen"
2430 PRINT TAB(30) "3  To disk file":  PRINT: PRINT TAB(30) "  Select";
2440 LOCATE,30:  GOSUB 150:  CLS: ON VAL(X$) GOTO 2450,2460,3000
2450 CLS: LOCATE 12,20: PRINT "Prepare printer & press Enter  ";: GOSUB 150
2451 OPEN "lpt1:" FOR OUTPUT AS #2
2452 GOTO 2500
2460 OPEN "scrn:" FOR OUTPUT AS #2
2500 '
2520 GOSUB 2610   'print page heading
2530 OPEN D$(1)+F$ AS 1 LEN=74
2540 FIELD 1, 12 AS NM$, 8 AS DSK$, 10 AS TY$, 25 AS DESCR$, 10 AS DT$, 7 AS SZ$    ,2 AS E$
2550   FOR I=1 TO LAST(1)
2560 GET 1, N(1,I)
2570 PRINT #2, NM$ " " DSK$" "TY$" "DESCR$" "DT$" "USING "###,###"; VAL(SZ$)
2571 Q$=INKEY$: IF Q$="" THEN 2580 ELSE L=CSRLIN
2572 LOCATE 25,3: PRINT"1-Continue  2-Start printing over  3-Start program over  4-End  ";: GOSUB 150:  IF X$="1" THEN LOCATE L,1: GOTO 2580
2573 IF X$="2" THEN 2400  ELSE IF X$="3" THEN RUN
2574 IF X$="4" THEN END ELSE 2571
2580 L=L+1: IF L>55 THEN PRINT #2, CHR$(12): GOSUB 2610
2590   NEXT
2600 CLOSE: GOSUB 150: RUN
2610 PRINT #2, TAB(30) "DISKCAT File Listing": PRINT #2, "":  L=1
2620 PRINT #2, " FILE NAME     DISK   FILE TYPE       DESCRIPTION             DATE      SIZE"
2630 PRINT #2, "------------ -------- --------- -------------------------  ---------- -------"
2640 RETURN
3000 LOCATE 12,20: LINE INPUT "enter output filename:  "; FI$
3010 CLS:' LOCATE 12,30: PRINT "doing it":
3020 OPEN D$(1)+F$ AS 1 LEN=74:  FIELD 1, 74 AS A$
3030 OPEN FI$ AS 2 LEN=74:       FIELD 2, 74 AS B$
3040   FOR I=1 TO LAST(1)
3050 GET 1,N(1,I):  LSET B$= A$:  PUT 2,I
3055 PRINT B$
3060   NEXT
3070 CLOSE:  CLOSE: RUN
B$
3040   FOR I=1 TO LAST(1)
3050 GET 1,N(1,I):  LSET B$= A$:  PUT 2,I
3055 PRINT B$
3060   NEX