100 DEFINT A-Z
110 FILL$="A"+CHR$(7)+"???ERROR"
120 ON ERROR GOTO 0
140 DIM TIT$(9),A3$(52)
160 INPUT "DATA FILE NAME?  ",F0$
180 OPEN "I",1,F0$+".TTL"
200 IF EOF(1) THEN PRINT "ERROR - NO *.TTL TITLES FILE" : STOP
220 FOR I=1 TO 9
240 IF EOF(1) THEN PRINT "ERROR - MUST HAVE 9 ENTRIES IN TITLES FILE.":GOTO 6060
260 INPUT #1,TIT$(I)
280 NEXT I
300 CLOSE 1
320 ON ERROR GOTO 620
340 OPEN "R",1,F0$+".LAB",128
350 FIELD #1,1 AS A0$,127 AS A1$
360 OPEN "R",2,F0$+".$$$",128
380 FIELD #2,128 AS A2$
400 RNI=1 : RNO=1
420 K=0
440 FOR I=1 TO 52
460 A3$(I)=FILL$
520 GET #1,RNI : RNI=RNI+1
540 IF EOF(1) THEN GOTO 820
560 IF A0$="I" THEN GOTO 800
580 IF A0$="A" THEN GOTO 760
600 PRINT "PROGRAM ERROR - BAD ACTIVE CODE" : GOTO 6060
620 PRINT "***CAUTION***";CHR$(7);CHR$(7)
640 PRINT "ERROR OCCURRED DURING FILE INPUT/REORGANIZATION - RESTART PROGRAM."
660 PRINT:PRINT "IF ERROR PERSISTS, GO TO BACKUP FILE BY RENAMING FILENAME.BAK"
680 PRINT "TO FILENAME.LAB, RUN PROGRAM, AND RE-ENTER ALL ACTIVITY FROM"
700 PRINT "LAST RUN." : PRINT
720 ON ERROR GOTO 0
740 GOTO 6060
760 K=K+1
780 A3$(K)=A0$+A1$
800 NEXT I
820 IF K=0 AND EOF(1) THEN GOTO 940
840 FOR I=1 TO K
860 LSET A2$=A3$(I)
880 PUT #2,RNO : RNO=RNO+1
900 NEXT I
920 IF NOT EOF(1) THEN GOTO 420
940 CLOSE 1 : CLOSE 2
960 NR = RNO-1
980 ON ERROR GOTO 6080
1000 OPEN "I",1,F0$+".BAK"
1020 CLOSE 1 : KILL F0$+".BAK" : GOTO 1060
1040 CLOSE 1
1060 ON ERROR GOTO 0
1080 NAME F0$+".LAB" AS F0$+".BAK"
1100 NAME F0$+".$$$" AS F0$+".LAB"
1120 PRINT : PRINT "THERE ARE ";NR;" ACTIVE RECORDS."
1140 PRINT
1160 PRINT "DO YOU WISH TO:"
1180 PRINT "  (1) ADD NAMES"
1200 PRINT "  (2) ALTER OR PRINT EXISTING NAMES"
1220 PRINT "  (3) QUIT"
1240 PRINT
1260 PRINT "ENTER NUMBER FROM ABOVE LIST  ";
1280 A$=INPUT$(1) : PRINT A$
1300 I=VAL(A$)
1320 IF I<1 OR I>3 THEN GOTO 1260
1340 ON I GOTO 1360,3340,6060
1360 GOSUB 5560
1380 RN=NR+1 : GOSUB 3660 : NR=NR+1
1400 IF A$="Q" OR A$="q" THEN CLOSE 1 : GOTO 1140 ELSE GOTO 1380
1420 REM
1440 REM
1460 REM
1480 PRINT
1500 PRINT "SHOULD LABELS BE PRINTED TO CONSOLE (C),"
1520 PRINT "LIST DEVICE (L), OR BOTH (B) ?  ";
1540 A$=INPUT$(1) : PRINT A$
1560 IF A$="C" OR A$="C" THEN CON=-1:LST= 0:GOTO 1640
1580 IF A$="L" OR A$="L" THEN CON= 0:LST=-1:GOTO 1640
1600 IF A$="B" OR A$="B" THEN CON=-1:LST=-1:GOTO 1640
1620 GOTO 1480
1640 PRINT
1660 PRINT "FROM THIS POINT ON, SHOULD LABELS BE PRINTED FOR ONLY"
1680 PRINT "SELECTED RECORDS (S) OR FOR ALL (A) ?  ";
1700 A$=INPUT$(1) : PRINT A$
1720 IF A$="S" OR A$="s" THEN GOTO 1780
1740 IF A$="A" OR A$="a" THEN TYP=0 : GOTO 1780
1760 PRINT "PLEASE REPLY 'S' OR 'A'." : GOTO 1640
1780 PRINT
1800 PRINT "DURING LABEL PRINTING:"
1820 PRINT "    CONTROL-S WILL SUSPEND PRINTING UNTIL ANY OTHER CHARACTER INPUT"
1840 PRINT "    CONTROL-C WILL CANCEL LABEL PRINTING"
1860 PRINT
1880 PRINT "AFTER THIS MESSAGE, THE PROGRAM WILL PAUSE FOR YOUR INPUT."
1900 PRINT "ENTER 'Y' TO IMMEDIATELY BEGIN PRINTING LABELS."
1920 PRINT "ENTER ANYTHING ELSE TO PRODUCE A TEST PATTERN TO AID IN"
1940 PRINT "LINING UP YOUR PRINTER.  AFTER THE PATTERN HAS BEEN"
1960 PRINT "PRINTED, 'Y' WILL BEGIN PRINTING, ANYTHING ELSE WILL"
1980 PRINT "REPEAT THE PATTERN."
2000 PRINT
2020 PRINT "   ***LINE UP YOUR PRINTER AND THEN RESPOND***"
2040 A$=INPUT$(1)
2060 IF A$="Y" OR A$="y" THEN GOTO 2280
2080 A$=STRING$(32,"X")
2100 FOR J=1 TO 2
2120 FOR I=1 TO 5
2140 IF CON THEN PRINT A$
2160 IF LST THEN LPRINT A$
2180 NEXT I
2200 IF CON THEN PRINT
2220 IF LST THEN LPRINT
2240 NEXT J
2260 GOTO 2040
2280 NLAB=0
2300 A$=INKEY$
2320 IF LEN(A$)=0 THEN GOTO 2420
2340 IF ASC(A$)=3 THEN GOTO 3040
2360 IF ASC(A$)<>19 THEN GOTO 2420
2380 A$=INKEY$
2400 IF LEN(A$)=0 THEN GOTO 2380
2420 IF ACT$="I" THEN GOTO 3020
2440 NLAB=NLAB+1
2460 A$ = ACCT$+"  "+DATE$+"  "+MISC$
2480 IF A$=STRING$(29," ") THEN A$=""
2500 IF CON THEN PRINT A$
2520 IF LST THEN LPRINT A$
2540 I=INSTR(NAM$,";")
2560 A$=RIGHT$(NAM$,25-I)
2580 J=INSTR(A$," ")
2600 IF J=0 THEN GOTO 2720
2620 J=J-1 : K=J
2640 IF K=LEN(A$) THEN A$=LEFT$(A$,J):GOTO 2720
2660 K=K+1
2680 IF MID$(A$,K,1)=" " THEN GOTO 2640
2700 J=K : GOTO 2640
2720 IF I>1 THEN A$=A$+" "+LEFT$(NAM$,I-1)
2740 IF CON THEN PRINT A$
2760 IF LST THEN LPRINT A$
2780 IF ADDR1$=STRING$(25," ") THEN GOTO 2840
2800 IF CON THEN PRINT ADDR1$
2820 IF LST THEN LPRINT ADDR1$
2840 IF CON THEN PRINT ADDR2$
2860 IF LST THEN LPRINT ADDR2$
2880 IF CON THEN PRINT CITY$;"  ";STATE$;" ";ZIP$
2900 IF LST THEN LPRINT CITY$;"  ";STATE$;" ";ZIP$
2920 IF CON THEN PRINT
2940 IF LST THEN LPRINT
2960 IF ADDR1$<>STRING$(25," ") THEN GOTO 3020
2980 IF CON THEN PRINT
3000 IF LST THEN LPRINT
3020 GOSUB 5780 : IF NOT ENDSW THEN GOTO 2300
3040 IF CON THEN PRINT STRING$(25,"*")
3060 IF LST THEN LPRINT STRING$(25,"*")
3080 IF CON THEN PRINT "*  FILENAME: ";F0$;TAB(25);"*"
3100 IF LST THEN LPRINT "*  FILENAME: ";F0$;TAB(25);"*"
3120 IF CON THEN PRINT USING "* LABELS PRINTED: ##### *";NLAB
3140 IF LST THEN LPRINT USING "* LABELS PRINTED: ##### *";NLAB
3160 IF CON THEN PRINT "*";STRING$(23," ");"*" : PRINT STRING$(25,"*")
3180 IF LST THEN LPRINT "*";STRING$(23," ");"*" : LPRINT STRING$(25,"*")
3200 IF CON THEN PRINT
3220 IF LST THEN LPRINT
3240 GOTO 1140
3260 REM
3280 '
3300 '
3320 '
3340 RN=0
3360 GOSUB 5560
3380 PRINT
3400 PRINT "THE FIELDS ARE DEFINED AS FOLLOWS:"
3420 FOR I=1 TO 9
3440 IF LEN(TIT$(I))<1 THEN GOTO 3480
3460 PRINT USING "  #) &";I,TIT$(I)
3480 NEXT I
3500 GOSUB 6200
3520 GOSUB 5780
3540 IF ENDSW THEN PRINT "**END OF FILE**" : PRINT : GOTO 1140
3560 IF ACT$="I" THEN GOTO 3520
3580 GOSUB 5000 : GOTO 3520
3600 '
3620 '
3640 '
3660 PRINT
3680 FOR FLD=1 TO 9
3700 GOSUB 4680
3720 NEXT FLD
3740 PRINT
3760 LSET ACT$="A"
3780 PRINT
3800 PRINT "(L,Q,?,0-9): "; : A$=INPUT$(1) : PRINT A$
3820 IF A$="?" THEN GOSUB 4100 : GOTO 3780
3840 IF A$="L" OR A$="l" THEN GOSUB 4300 : GOTO 3780
3860 IF A$="Q" OR A$="q" THEN GOTO 3980
3880 IF A$<"0" OR A$>"9" THEN GOSUB 4100 : GOTO 3780
3900 FLD=VAL(A$)
3920 IF FLD=0 THEN GOTO 3980
3940 GOSUB 4680
3960 GOTO 3780
3980 PUT #1,RN
4000 PRINT
4020 RETURN
4040 '
4060 '
4080 '
4100 PRINT "THE FOLLOWING ENTRIES ARE ALLOWED:"
4120 PRINT "   L  -TO LIST THE CURRENT RECORD"
4140 PRINT "   Q  -IF DONE ENTERING NEW NAMES"
4160 PRINT "   0  -IF DONE WITH THIS RECORD"
4180 PRINT "   A NUMBER FROM 1 TO 9 TO CHANGE THE"
4200 PRINT "     CORRESPONDING FIELD OF THE CURRENT RECORD"
4220 RETURN
4240 '
4260 '
4280 '
4300 FOR I=1 TO 9
4320 ON I GOTO 4360,4380,4400,4420,4440,4460,4480,4500,4520
4340 PRINT "WOW! THIS CAN'T HAPPEN! (RECORD PRINT ROUTINE)":GOTO 6060
4360 A$=NAM$:GOTO 4540
4380 A$=ADDR1$:GOTO 4540
4400 A$=ADDR2$:GOTO 4540
4420 A$=CITY$:GOTO 4540
4440 A$=STATE$:GOTO 4540
4460 A$=ZIP$:GOTO 4540
4480 A$=ACCT$:GOTO 4540
4500 A$=DATE$:GOTO 4540
4520 A$=MISC$
4540 IF LEN(TIT$(I)+A$)<1 THEN GOTO 4580
4560 PRINT USING "#) & &";I,TIT$(I),A$
4580 NEXT I
4600 RETURN
4620 '
4640 '
4660 '
4680 IF LEN(TIT$(FLD))<1 THEN A$="":GOTO 4720
4700 PRINT TIT$(FLD); : LINE INPUT A$
4720 ON FLD GOTO 4760,4780,4800,4820,4840,4860,4880,4900,4920
4740 PRINT "PROGRAM ERROR - BAD FIELD NUMBER" : GOTO 6060
4760 LSET NAM$= A$ : RETURN
4780 LSET ADDR1$=A$ : RETURN
4800 LSET ADDR2$=A$ : RETURN
4820 LSET CITY$= A$ : RETURN
4840 LSET STATE$=A$ : RETURN
4860 LSET ZIP$=  A$ : RETURN
4880 LSET ACCT$= A$ : RETURN
4900 LSET DATE$= A$ : RETURN
4920 LSET MISC$= A$ : RETURN
4940 '
4960 '
4980 '
5000 PRINT
5020 GOSUB 4300
5040 GOTO 5240
5060 PRINT
5080 PRINT "ENTER FIELD NUMBER TO CHANGE OR:"
5100 PRINT "    C TO CHANGE RECORD SELECTION CRITERIA"
5120 PRINT "    D TO DELETE THIS RECORD"
5140 PRINT "    L TO LIST THE CURRENT RECORD (INCLUDING ANY CHANGES)"
5160 PRINT "    N TO GET NEXT RECORD WITHOUT CHANGING THIS ONE"
5180 PRINT "    P TO PRINT LABELS STARTING WITH THE CURRENT RECORD"
5200 PRINT "    Q TO QUIT THIS FUNCTION AND RETURN TO MAIN MENU"
5220 PRINT "    S TO GET NEXT RECORD AFTER SAVING CHANGES ALREADY MADE"
5240 PRINT:PRINT "ACTION(C,D,L,N,P,Q,S,?,1-9): ";:A$=INPUT$(1):PRINT A$
5260 IF A$="C" OR A$="c" THEN GOSUB 6200:GOTO 5240
5280 IF A$="N" OR A$="n" THEN RETURN
5300 IF A$="P" OR A$="p" THEN GOTO  1480
5320 IF A$="S" OR A$="s" THEN PUT #1,RN : RETURN
5340 IF A$="Q" OR A$="q" THEN PUT #1,RN : CLOSE 1 : GOTO 1140
5360 IF A$="L" OR A$="l" THEN GOTO 5000
5380 IF A$="D" OR A$="d" THEN LSET ACT$="I":PUT #1,RN : RETURN
5400 IF A$="?" THEN GOTO 5060
5420 FLD=VAL(A$)
5440 IF FLD<1 OR FLD>9 THEN PRINT "INVALID ENTRY";CHR$(7) : GOTO 5060
5460 GOSUB 4680
5480 GOTO 5240
5500 '
5520 '
5540 '
5560 OPEN "R",1,F0$+".LAB",128
5580 FIELD #1,1 AS ACT$,25 AS NAM$,25 AS ADDR1$,25 AS ADDR2$,15 AS CITY$,

    2 AS STATE$,9 AS ZIP$,6 AS ACCT$,6 AS DATE$,14 AS MISC$
5600 ENDSW=0
5620 RETURN
5640 '
5660 '
5680 '
5700 REM
5720 REM
5740 REM  ---ROUTINE TO GET NEXT RECORD---
5760 REM
5780 RN=RN+1 : IF RN>NR THEN CLOSE 1 : ENDSW=-1 : RETURN
5800 GET #1,RN
5820 IF TYP=0 THEN RETURN
5840 ON TYP GOTO 5880,5900,5920,5940,5960,5980,6000,6020,6040
5860 PRINT "PROGRAM ERROR - INVALID SELECT TYPE":GOTO 6060
5880 IF INSTR(NAM$,AA$)<>0 THEN RETURN ELSE GOTO 5780
5900 IF INSTR(ADDR1$,AA$)<>0 THEN RETURN ELSE GOTO 5780
5920 IF INSTR(ADDR2$,AA$)<>0 THEN RETURN ELSE GOTO 5780
5940 IF INSTR(CITY$,AA$)<>0 THEN RETURN ELSE GOTO 5780
5960 IF INSTR(STATE$,AA$)<>0 THEN RETURN ELSE GOTO 5780
5980 IF INSTR(ZIP$,AA$)<>0 THEN RETURN ELSE GOTO 5780
6000 IF INSTR(ACCT$,AA$)<>0 THEN RETURN ELSE GOTO 5780
6020 IF INSTR(DATE$,AA$)<>0 THEN RETURN ELSE GOTO 5780
6040 IF INSTR(MISC$,AA$)<>0 THEN RETURN ELSE GOTO 5780
6060 CLOSE : PRINT "PROGRAM TERMINATED." : STOP
6080 IF ERR=53 THEN RESUME 1040
6100 ON ERROR GOTO 0
6120 PRINT "SOME UNKNOWN ERROR"
6140 GOTO 6060
6160 '
6180 '
6200 PRINT : PRINT "ENTER THE FIELD NUMBER YOU WISH TO SELECT ON"
6220 PRINT "OR ZERO TO SELECT ALL RECORDS:  ";
6240 A$=INPUT$(1) : PRINT A$ : PRINT
6260 IF A$<"0" OR A$>"9" THEN PRINT "ENTRY MUST BE 0-9":GOTO 6200
6280 TYP=VAL(A$)
6300 IF TYP<0 OR TYP>9 THEN PRINT "ENTRY MUST BE 0-9":GOTO 6200
6320 AA$=""
6340 IF TYP>0 THEN LINE INPUT "ENTER STRING YOU ARE SEARCHING FOR:";AA$
6360 RETURN
6380 '
6400 '
6420 END

6320 AA$=""
6340 IF TYP>0 THEN L