10 DIM A$(255)
90 PRINT CHR$(26):PRINT 
92 PRINT"          Another Basic Cataloger"
93 PRINT"            by Hamilton Davies":PRINT
95  PRINT "           press + to EXIT to CPM":PRINT:PRINT:PRINT
100 PRINT "            1 = FIND BY NAME"
105 PRINT
110 PRINT "            2 = FIND BY DISK"
115 PRINT
120 PRINT "            3 = ADD A NEW DISK"
125 PRINT
130 PRINT "            4 = UPDATE OLD DISK"
131 PRINT
132 PRINT "            5 = TURN PRINTER ";:IF PNT THEN PRINT"off":GOTO 138
134 PRINT "on"
138 PRINT:PRINT:PRINT:PRINT:PRINT
140 IF FST=0 THEN PRINT"     press * ONLY if you are starting a new catalog"
150 K$=INKEY$:K=VAL(K$):IF K$="" THEN 150
155 IF K=0 THEN 400
157 RESET
160 ON K GOSUB 1000,2000,3000,4000,200
170 GOTO 90
200 IF PNT THEN PNT=0:RETURN
210 PNT=1:RETURN
300 LPRINT B$;"     ";D
310 PGE=PGE+1:IF PGE >55 THEN PRINT CHR$(7);"change paper and press any key"
315 IF PGE > 55 THEN LPRINT CHR$(12);
320 IF PGE > 55 THEN IF INKEY$="" THEN 320 ELSE PGE =0
330 RETURN
400 IF K$= "*" THEN FST = 1 :GOTO 90
410 IF K$="+" THEN SYSTEM
420 GOTO 90
500 LPRINT LEFT$(B$,13);
510 LNE=LNE+1:IF LNE>3 THEN LNE=0:LPRINT " ";N:PGE=PGE+1
515 IF PGE=7 THEN LPRINT:PGE=1:LPRINT
520 RETURN
600 PRINT "*** PRESS ANY KEY WHEN PRINTER IS READY ***"
610 IF INKEY$="" THEN 610
615 LNE=0:PNT=0:PGE=1
630 LPRINT CHR$(27);CHR$(81);CHR$(27);CHR$(66);
650 RETURN
660 LPRINT CHR$(27);CHR$(65);CHR$(27);CHR$(78)
665 FOR T=PGE TO 5:LPRINT:NEXT T
670 RETURN
700 STOP
1000 INPUT "FILENAME,EXTENSION, OR . FOR ALL";A$:N=0
1005 PGE = 0
1010 OPEN "I",#1,"A:CATALOG.DAT"
1015 IF N THEN A$="#$%^&"
1020 INPUT #1,NUMFILE
1030 INPUT #1,LASTDISK
1040 FOR T= 1 TO NUMFILE
1045 IF EOF(1) THEN 1085
1050 INPUT #1,B$
1060 INPUT #1,D
1070 IF INSTR(1,B$,A$) OR D = N THEN PRINT B$,D:IF PNT THEN GOSUB 300
1075 IF D=N AND LBL=1 THEN GOSUB 500
1080 NEXT T
1085 CLOSE #1
1090 PRINT "END OF FILE.  PRESS ANY KEY"
1095 IF PNT THEN LPRINT CHR$(12);
1100 IF INKEY$="" THEN 1100
1105 IF LBL=1 THEN GOSUB 660: LBL=0  
1110 RETURN
2000 INPUT " ENTER NUMBER OF DISK";N
2005 INPUT " WOULD YOU LIKE TO MAKE A DISK LABEL";A$
2010 IF LEFT$(A$,1)="Y" THEN LBL=1: GOSUB 600
2015 A$=""
2020 GOTO 1010
3000 PRINT "THE NEW DISK MUST BE XDIR'ED FIRST"
3030 PRINT "PLACE DISK WITH FILE DISK.DIR IN DRIVE B:"
3040 PRINT "PRESS <RETURN> WHEN READY OR <A> TO ABORT"
3050 IF INKEY$= "A" THEN RETURN
3055 IF INKEY$<>CHR$(13) THEN GOTO 3050
3060 IF FST THEN GOTO 3105
3100 NAME "A:CATALOG.DAT" AS "A:CATALOG.TMP"
3105 A=2
3110 OPEN "I",#1,"B:DISK.DIR"
3115 I=0:INPUT #1,A$: I=INSTR(1,A$,":")
3120 IF I THEN A$(1)=MID$(A$,I-18,17):A=3
3125 A$(A-1)=RIGHT$(A$,17)
3130 IF EOF(1) THEN 3160
3135 INPUT #1,A$:IF INSTR(1,A$," :") THEN A$(A)=RIGHT$(A$,17):A=A+1
3140 A$(A)=LEFT$(A$,17)
3150 A=A+1
3155 GOTO 3130
3160 CLOSE #1
3170 A=A-7
3200 FOR X= 1 TO A-1:FOR Y=X+1 TO A
3210 IF A$(Y)<A$(X) THEN SWAP A$(X),A$(Y)
3220 NEXT Y: NEXT X
3225 IF FST THEN GOTO 5000
3300 OPEN "I",#1,"A:CATALOG.TMP"
3310 OPEN "O",#2,"A:CATALOG.DAT"
3320 INPUT #1,NUMFILE:NUMFILE=NUMFILE+A:PRINT #2,NUMFILE
3330 INPUT #1,LASTDISK:LASTDISK=LASTDISK+1:PRINT #2,LASTDISK
3335 PRINT " THIS DISK WILL BE NUMBER";LASTDISK
3340 B=1
3345 IF EOF(1) THEN GOTO 3400
3350 INPUT #1,A$:INPUT #1,D
3355 IF B>A THEN GOTO 3370
3360 IF A$(B) < A$ THEN PRINT #2,A$(B):PRINT #2,LASTDISK :B=B+1:GOTO 3355
3370 PRINT #2,A$:PRINT #2,D
3380 GOTO 3345
3400 CLOSE #1
3410 IF B>A THEN CLOSE #2:KILL "A:CATALOG.TMP":RETURN
3420 FOR T= B TO A
3430 PRINT #2,A$(T):PRINT #2,LASTDISK
3440 NEXT T
3450 CLOSE #2:KILL "A:CATALOG.TMP": RETURN
4000 PRINT " ENTER THE NUMBER OF THE DISK TO UPDATE"
4010 INPUT "DISK NUMBER";N
4020 OPEN "I",#1,"A:CATALOG.DAT"
4030 INPUT #1,NUMFILE
4035 INPUT #1,LASTDISK
4040 BLANK=0:FOR T= 1 TO NUMFILE STEP 2
4042 INPUT #1,A$:INPUT #1,B:IF B=N THEN BLANK=BLANK+1
4045 NEXT T:CLOSE #1
4050 CLOSE #1
4060 IF N>LASTDISK THEN PRINT "YOU NEED TO ADD A NEW DISK":RETURN
4070 PRINT "PLACE DISK TO BE UPDATED IN DRIVE B:"
4080 PRINT "PRESS <RETURN> WHEN READY OR <A> TO ABORT"
4090 IF INKEY$="A" THEN RETURN
4100 IF INKEY$<>CHR$(13) THEN GOTO 4090
4105 A=2
4110 OPEN "I",#1,"B:DISK.DIR"
4115 I=0:INPUT #1,A$:I=INSTR(1,A$,":")
4120 IF I THEN A$(1)=MID$(A$,I-18,17):A=3
4125 A$(A-1)=RIGHT$(A$,17)
4130 IF EOF(1) THEN 4160
4135 INPUT #1,A$:IF INSTR(1,A$," :") THEN A$(A)=RIGHT$(A$,17):A=A+1
4140 A$(A)=LEFT$(A$,17)
4150 A=A+1
4155 GOTO 4130
4160 CLOSE #1
4170 A=A-7
4200 FOR X= 1 TO A-1:FOR Y= X+1 TO A
4210 IF A$(Y)<A$(X) THEN SWAP A$(X),A$(Y)
4220 NEXT Y: NEXT X
4300 B=1
4310 NAME "A:CATALOG.DAT" AS "A:CATALOG.TMP"
4320 OPEN "I",#1,"A:CATALOG.TMP"
4330 OPEN "O",#2,"A:CATALOG.DAT"
4335 INPUT #1,NUMFILE:INPUT #1,LASTDISK
4340 PRINT #2,NUMFILE+A-BLANK:PRINT #2,LASTDISK
4345 IF EOF(1) THEN 4400
4350 INPUT #1,A$:INPUT #1,D
4355 IF B>A THEN GOTO 4365
4360 IF A$(B) < A$ THEN PRINT #2,A$(B):PRINT #2,N:B=B+1
4365 IF D=N THEN GOTO 4345
4370 PRINT #2,A$:PRINT #2,D
4380 GOTO 4345
4400 CLOSE #1
4410 IF B>A THEN CLOSE #2:KILL "A:CATALOG.TMP":RETURN
4420 FOR T= B TO A
4430 PRINT #2,A$(T):PRINT #2,N
4440 NEXT T
4450 CLOSE #2:KILL "A:CATALOG.TMP" :RETURN
5000 OPEN "O",#1,"A:CATALOG.DAT"
5010 PRINT #1,A:PRINT #1,1
5020 FOR T=1 TO A:PRINT #1,A$(T)
5030 PRINT #1,1
5040 NEXT T
5050 CLOSE #1
5055 FST=0
5060 RETURN
PRINT 