6 GOTO 10
7 SAVE "NAMEADDR.BAS",A:STOP
9 ' Based on:
10 ' SUPMAIL.BAS   Mailing label program for 'Business Mailing Labels'
20 ' MBASIC 5.2  CP/M ver   08/29/81   from Missasauga RCPM
30 ' H19/H89/Z89 device depen clear scr & rev video
40 ' Written by:      Alden C. Olander III  <AL>
80 ' Modified by:     Paul J. Mayer, Jr.
90 '                  Thomas E. McCormick converted from HDOS to CP/M.
120 CLEAR 10000
130 DIM A$(250),A1$(250),A2$(250),A3$(250),A4$(250),A5$(250),A6$(250),A7$(250)
135 ON ERROR GOTO 140
140 E$=CHR$(27):PRINT E$;"E":PRINT:PRINT:PRINT
150 PRINT TAB(10);E$;"p";"  NAMEADDR mailing list program.  ";E$;"q":PRINT
160 PRINT "    The following options are available:"
170 PRINT 
180 PRINT "0 - READ OR WRITE NAMES ON DISK"
190 PRINT "1 - ADD NEW NAMES TO THE LIST"
200 PRINT "2 - DELETE NAMES FROM THE LIST"
210 PRINT "3 - PRINT LABELS"
220 PRINT "4 - SEARCH BY LAST NAME, CITY, OR STATE AND PRINT"
230 PRINT "5 - FINISH: EXIT THIS PROGRAM."
240 PRINT "6 - EXCHANGE DATA DISK IN DRIVE 'B:'"
250 PRINT "7 - ALPHABETIZE YOUR DATA LIST ON DISK"
260 PRINT "8 - CHANGE/CORRECT INFORMATION IN DATA FILE"
265 PRINT "9 - PRINT ROSTER OF NAMES AND OTHER INFORMATION"
270 PRINT:PRINT:PRINT:PRINT
280 INPUT "WHICH OPTION DO YOU WANT? (0,1,2,3,4,5,6,7,8 OR 9) - ";N1
290 ON N1 GOSUB 1000,2000,3000,4000
300 IF N1=0 THEN GOSUB 5170
310 IF N1=5 THEN GOTO 5000
320 IF N1=6 THEN GOSUB 6000
330 IF N1=7 THEN GOSUB 7000
340 IF N1=8 THEN GOSUB 8000
345 IF N1=9 THEN GOSUB 9000
350 IF N1>=9 THEN PRINT "WRONG NUMBER  - TRY AGAIN!!":PRINT :GOTO 280
360 GOTO 170
1000 PRINT E$;"E"
1010 PRINT "TO STOP INPUT TYPE 'NONE' FOR LAST NAME "
1020 PRINT
1030 PRINT 
1040 R=R+1
1050 '----------------------------------------------------------------
1060 PRINT TAB(5);R;"  ";:LINE INPUT "LAST NAME ? ";A$(R)
1070 IF A$(R)="NONE" OR A$(R)="none" THEN R=R-1:PRINT E$;"E":RETURN 
1075 PRINT TAB(5);R;"  ";:LINE INPUT "FIRST NAME, MIDDLE INITIAL? ";A2$(R)
1080 PRINT TAB(5);R;"  ";:LINE INPUT "STREET ADDRESS? ";A1$(R)
1090 PRINT TAB(5);R;"  ";:LINE INPUT "CITY? ";A3$(R)
1100 PRINT TAB(5);R;"  ";:LINE INPUT "STATE? ";A4$(R)
1110 PRINT TAB(5);R;"  ";:LINE INPUT "ZIP CODE? ";A5$(R)
1111 PRINT TAB(5);R;"  ";:LINE INPUT "HOME PHONE? ";A6$(R)
1112 PRINT TAB(5);R;"  ";:LINE INPUT "BUSINESS PHONE? ";A7$(R)
1120 PRINT:LINE INPUT"  IS THIS INFO CORRECT?  (Y OR N)   ";B$
1130 IF B$="N" THEN GOSUB 7190:GOTO 1050
1140 FOR I=1 TO 4:PRINT :NEXT I
1150 GOTO1010
2000 PRINT E$;"E"
2010 PRINT "     This part of the program will delete a name.   You may"
2020 PRINT "     locate the desired line by agency name or city.
2030 PRINT "     BE CAREFUL: DELETED INFORMATION CANNOT BE RECOVERED."
2050 PRINT:PRINT:PRINT:PRINT
2060 PRINT "     0 - RETURN TO MAIN PROGRAM"
2070 PRINT "     1 - LOCATE INFORMATION FOR DELETE BY LAST NAME"
2080 PRINT "     2 - LOCATE INFORMATION FOR DELETE BY CITY"
2090 PRINT:PRINT:PRINT:PRINT
2100 LINE INPUT "WHICH OPTION DO YOU WANT? (0,1, OR 2)  <0> ";N1$
2110 IF N1$="" OR N1$="0" THEN PRINT E$;"E":RETURN 
2120 IF N1$="1" OR N1$="2" THEN GOSUB 4170
2130 IF N1$="1" OR N1$="2" THEN GOTO 2150
2140 GOTO 2050
2150 PRINT :LINE INPUT "DO YOU WANT TO DELETE THIS INFORMATION? ";N$
2160 IF LEFT$(N$,1)="Y" THEN GOSUB 2180
2170 GOTO 2050
2180 FOR I=1 TO 4:PRINT :NEXT I
2190 PRINT "WHEN YOU ENTER THE NUMBER THINK BEFORE HITTING RETURN!!"
2200 PRINT "IF YOU HAVE CHANGED YOUR MIND THEN ENTER A '0' "
2210 INPUT "WHAT IS THE NUMBER OF THE RECORD TO BE DELETED? ";X
2220 IF X=0 THEN A$="":RETURN 
2230 PRINT E$;"E";E$;"p";
2240 PRINT "  HOLD TIGHT! I'M WORKING ON YOUR DATA - BE PATIENT  ";E$;"q"
2250 A$(X)="":A1$(X)="":A2$(X)="":A3$(X)="":A4$(X)="":A5$(X)="":
2255 A6$(X)="":A7$(X)=""
2260 FOR D= X TO R
2270 A$(D)=A$(D+1):A1$(D)=A1$(D+1):A2$(D)=A2$(D+1):A3$(D)=A3$(D+1)
2280 A4$(D)=A4$(D+1):A5$(D)=A5$(D+1):A6$(D)=A6$(D+1):A7$(D)=A7$(D+1)
2290 NEXT D
2300 R=R-1:RETURN 
3000 PRINT E$;"E":PRINT :PRINT :PRINT :PRINT :PRINT 
3010 PRINT "     0 - RETURN TO MAIN PROGRAM"
3020 PRINT "     1 - TYPE ALL LABELS IN FILE"
3030 PRINT "     2 - TYPE LABELS FOR xxxxx ZIP CODE"
3040 FOR I=1 TO 4:PRINT :NEXT I
3050 LINE INPUT "     WHICH OPTION DO YOU WANT? (0,1, OR 2) <0> ";P$
3060 IF P$="" OR P$="0" THEN PRINT E$;"E":PRINT :PRINT :PRINT :PRINT :PRINT :RETURN 
3070 IF P$="1" THEN 3110
3080 IF P$="2" THEN 3220
3090 PRINT "  THAT'S NOT A VALID CHOICE ! TRY AGAIN.."
3100 FOR I=1 TO 4:PRINT :NEXT I:GOTO 3010
3110 FOR I=1 TO 4:PRINT :NEXT I
3120 INPUT "  WHAT IS THE NUMBER OF LINES YOU WANT BETWEEN LABELS? ";L
3130 GOSUB 3340
3140 FOR I=1 TO R
3150 PRINT #2,"  ";A2$(I);" ";A$(I)
3160 PRINT #2,"  ";A1$(I)
3170 PRINT #2,"  ";A3$(I);", ";A4$(I);" ";A5$(I)
3180 FOR J=1 TO L:PRINT #2,:NEXT J
3190 NEXT I
3200 CLOSE #2
3210 GOTO 3010
3220 FOR I=1 TO 4:PRINT :NEXT I
3230 INPUT "  WHAT IS THE NUMBER OF LINES YOU WANT BETWEEN LABELS? ";L
3240 LINE INPUT "WHAT IS THE ZIP FOR YOUR LABELS? ";B$
3250 GOSUB 3340
3260 FOR I=1 TO R
3270 IF B$=A5$(I) THEN PRINT #2,"  ";A2$(I);" ";A$(I)
3280 IF B$=A5$(I) THEN PRINT #2,"  ";A1$(I)
3290 IF B$=A5$(I) THEN PRINT #2,"  ";A3$(I);", ";A4$(I);" ";A5$(I)
3300 IF B$=A5$(I) THEN FOR J=1 TO L:PRINT #2,:NEXT J
3310 NEXT I
3320 CLOSE #2
3330 GOTO 3010
3340 PRINT E$;"E":PRINT :PRINT :PRINT :PRINT :PRINT 
3350 LINE INPUT "  Output to SCREEN or PRINTER ? (S or P) <S>  ";S$
3360 IF LEFT$(S$,1)="P" THEN OPEN "O",#2,"LP:":RETURN
3370 IF LEFT$(S$,1)="p" THEN OPEN "O",#2,"LP:":RETURN
3380 OPEN "O",#2,"TT:":RETURN
4000 FOR I=1 TO 24:PRINT :NEXT I
4010 PRINT "     This is the search and find option."
4020 PRINT "     You may locate a specific LAST NAME, CITY,"
4030 PRINT "     or all those listed under a STATE."
4040 PRINT 
4050 PRINT 
4060 PRINT "     0 - RETURN TO MAIN PROGRAM"
4070 PRINT "     1 - LOCATE BY LAST NAME"
4080 PRINT "     2 - LOCATE BY CITY"
4090 PRINT "     3 - LOCATE ALL IN STATE"
4100 FOR I=1 TO 4:PRINT :NEXT I
4110 LINE INPUT "WHICH OPTION DO YOU WANT? (0,1,2 OR 3)  <0> ";N1$
4120 IF N1$="" OR N1$="0" THEN PRINT E$;"E":PRINT :PRINT :PRINT :PRINT :PRINT :RETURN 
4130 IF N1$="1" THEN GOSUB 4170
4140 IF N1$="2" THEN GOSUB 4170
4150 IF N1$="3" THEN GOSUB 4170
4160 GOTO 4040
4170 FOR I=1 TO 24:PRINT :NEXT I
4180 IF N1$="1" THEN PRINT "WHAT IS THE LAST NAME YOU ARE LOOKING FOR? ";
4190 IF N1$="2" THEN PRINT "WHAT IS THE CITY? ";
4200 IF N1$="3" THEN PRINT "WHAT IS THE STATE? ";
4210 LINE INPUT B$
4220 FOR I=1 TO 4:PRINT :NEXT I
4230 X=1
4240 FOR I=1 TO R
4250 IF B$=A$(I) THEN 4320
4260 IF B$=A3$(I) THEN 4320
4270 IF B$=A4$(I) THEN 4320
4280 X=X+1
4290 NEXT I
4300 IF X=I THEN PRINT " NOT ON THIS LIST ":GOTO 4170
4310 RETURN 
4320 PRINT 
4330 PRINT I;" ";A2$(I);" ";A$(I)
4340 PRINT A1$(I)
4350 PRINT A3$(I);", ";A4$(I);" ";A5$(I)
4351 PRINT A6$(I);" ";A7$(I)
4355 FOR P=1 TO 300:NEXT P
4360 PRINT 
4370 GOTO 4290
5000 PRINT E$;"E"
5010 PRINT 
5020 FOR I=1 TO 4:PRINT :NEXT I
5030 PRINT "     REMEMBER, if you exit the program without saving"
5040 PRINT "     your new data,  the disk file is the same as it was"
5050 PRINT "     when you started!  If you made CHANGES you must"
5060 PRINT "     SAVE THE NEW DATA!!!!":PRINT 
5070 PRINT E$;"p";" HAVE YOU SAVED YOUR NEW DATA TO YOUR DISK FILE? ";E$;"q"
5075 PRINT
5080 LINE INPUT "  <YES OR NO> ? ";N$
5090 IF LEFT$(N$,1)="N" THEN GOSUB 5170:GOTO 5110
5100 IF LEFT$(N$,1)<>"Y" THEN GOTO 5000
5110 CLOSE #1
5120 CLOSE #2
5130 PRINT :PRINT :PRINT "  IF YOU GOOFED AND DID NOT SAVE YOUR DATA YOU MAY RESTART THE PROGRAM"
5140 PRINT "  BY TYPING 'RUN 140' <CR> ... AND THE PROGRAM"
5150 PRINT "  WILL RESTART WITH YOUR DATA INTACT!!!"
5160 END 
5170 PRINT E$;"E"
5180 C$=CHR$(34)
5190 PRINT "     0 - RETURN TO MAIN PROGRAM"
5200 PRINT "     1 - GET LIST FROM DISK FILE"
5210 PRINT "     2 - PUT LIST ON DISK":PRINT 
5220 PRINT "     NOTE: If you PUT your files to the disk and have"
5230 PRINT "     not previously gotten all info from the disk you"
5240 PRINT "     will save only the info in the computer and will"
5250 PRINT "     ERASE your disk file.......THINK FIRST.":PRINT 
5260 LINE INPUT "     WHICH OPTION DO YOU WANT? (0,1, OR 2) <0> ";N$
5270 IF N$="" OR N$="0" THEN GOTO 140
5280 IF N$="1" THEN GOSUB 5530
5290 IF N$="2" THEN GOSUB 5530
5300 IF N$="1" THEN 5330
5310 IF N$="2" THEN 5430
5320 PRINT :PRINT :PRINT :GOTO 5190
5330 PRINT E$;"E"
5340 PRINT E$;"p";TAB(10);" Please wait while I read your data ! ";
5350 PRINT E$;"q"
5360 OPEN "I",#1,D$
5370 INPUT #1,R
5380 FOR I=1 TO R
5390 INPUT #1,A$(I),A1$(I),A2$(I),A3$(I),A4$(I),A5$(I),A6$(I),A7$(I)
5400 NEXT I
5410 CLOSE #1
5415 PRINT E$;"E":FOR X=1 TO 6:PRINT:NEXT X
5420 RETURN 
5430 PRINT E$;"E"
5440 PRINT E$;"p";TAB(10);" Please wait while I put your data away. ";
5450 PRINT E$;"q"
5460 OPEN "O",#1,D$
5470 PRINT #1,R
5480 FOR I=1 TO R
5490 PRINT #1,C$;A$(I);C$;",";C$;A1$(I);C$;",";C$;A2$(I);C$;",";C$;
5495 PRINT A3$(I);C$;",";C$;",";C$;A4$(I);C$;",";C$;A5$(I);C$;",";
5497 PRINT C$;A6$(I);C$;",";C$;A7$(I);C$
5500 NEXT I
5510 CLOSE #1
5520 RETURN 
5530 LINE INPUT "  What is the NAME of your data file? <ie.  B:NAMEADDR.DAT> ";D$
5540 IF D$="" THEN LET D$="B:NAMEADDR.DAT"
5550 RETURN 
6000 RESET "B:"
6010 GOTO 140
7000 CLEAR (15000):DIM A$(200):I%=1
7010 FOR I=1 TO 24:PRINT :NEXT I
7020 PRINT "  This section of the program will alphabetize your"
7030 PRINT "data file.  You will be asked for the file to be"
7040 PRINT "sorted 'eg. B:NAMEADDR.DAT' and the output file name"
7050 PRINT "which you must give a different name to such as"
7060 PRINT "eg. 'B:NAMEALPH.DAT'."
7070 PRINT
7080 PRINT
7090 INPUT "Incoming FILE NAME to be sorted.. ";P$:INPUT "Output FILE NAME for sorted file  <ie. B:NAMEALPH.SRT> ";T$
7095 IF T$="" THEN LET T$="B:NAMEALPH.SRT"
7100 OPEN "I",1,P$:OPEN "O",2,T$
7110 IF EOF(1) THEN 7120 ELSE LINE INPUT#1,A$(I%):I%=I%+1:GOTO 7110
7120 I%=I%-1:C%=I%:B%=I%
7130 C%=INT(C%/2):PRINT C%:IF C%=0 THEN 7180 ELSE D%=1:E%=B%-C%
7140 F%=D%
7150 G%=F%+C%:IF A$(F%)<=A$(G%) THEN 7170
7160 SWAP A$(F%),A$(G%):F%=F%-C%:IF F%<1 THEN 7170 ELSE 7150
7170 D%=D%+1:IF D%>E% THEN 7130 ELSE 7140
7180 FOR X%=1 TO I%:PRINT #2,A$(X%):NEXT X%:CLOSE:GOTO 120
7190 PRINT CHR$(27);CHR$(69):FOR I=1 TO 6:PRINT:NEXT I:RETURN
8000 '
8010 ' ** CORRECTION ROUTINE **
8110 '
8120 PRINT E$;"E":FOR X=1 TO 6:PRINT:NEXT X
8130 PRINT "YOU CAN SEARCH BY LAST NAME OR CITY"
8140 PRINT "TO FIND ENTRY TO BE CORRECTED.":PRINT :PRINT 
8150 PRINT "0 - RETURN TO MAIN MENU"
8160 PRINT "1 - SEARCH BY LAST NAME"
8170 PRINT "2 - SEARCH BY CITY "
8180 PRINT :INPUT "WHICH OPTION DO YOU WANT?  <0,1, OR 2>  <0>  ";N1$
8190 IF N1$="" OR N1$="0" THEN GOTO 140
8210 IF N1$="1" THEN GOSUB 4170
8220 IF N1$="2" THEN GOSUB 4170
8230 INPUT "WHAT IS THE NUMBER OF THE RECORD TO BE CHANGED? ";X
8240 J=X
8250 GOTO 8280
8260 IF N1$=0 THEN 140
8270 GOTO 8110
8280 ' MAKE ENTRY CORRECTION
8290 PRINT E$;"E":FOR X=1 TO 6:PRINT:NEXT X
8300 PRINT "Make Corrections on your data. If no change hit CR."
8310 PRINT "OLD LAST NAME IS - ";A$(J)
8320 LINE INPUT "NEW LAST NAME - ";H$(J)
8330 IF H$(J)="" THEN H$(J)=A$(J)
8331 PRINT "OLD FIRST NAME AND MIDDLE INITIAL IS - ";A2$(J)
8332 LINE INPUT "NEW FIRST NAME AND MIDDLE INITIAL - ";H2$(J)
8333 IF H2$(J)=""THEN H2$(J)=A2$(J)
8340 PRINT "OLD STREET ADDRESS IS - ";A1$(J)
8350 LINE INPUT "NEW STREET ADDRESS IS - ";H1$(J)
8360 IF H1$(J)="" THEN H1$(J)=A1$(J)
8370 PRINT "OLD CITY - ";A3$(J)
8380 LINE INPUT "NEW CITY - ";H3$(J)
8390 IF H3$(J)="" THEN H3$(J)=A3$(J)
8400 PRINT "OLD STATE - ";A4$(J)
8410 LINE INPUT "NEW STATE - ";H4$(J)
8420 IF H4$(J)="" THEN H4$(J)=A4$(J)
8430 PRINT "OLD ZIP CODE - ";A5$(J)
8440 LINE INPUT "NEW ZIP CODE - ";H5$(J)
8450 IF H5$(J)="" THEN H5$(J)=A5$(J)
8451 PRINT "OLD HOME PHONE - ";A6$(J)
8452 LINE INPUT "NEW HOME PHONE - ";H6$(J)
8453 IF H6$(J)="" THEN H6$(J)=A6$(J)
8454 PRINT "OLD BUSINESS PHONE - ";A7$(J)
8455 LINE INPUT "NEW BUSINESS PHONE -";H7$(J)
8456 IF H7$(J)="" THEN H7$(J)=A7$(J)
8460 PRINT E$;"E":FOR X=1 TO 6:PRINT:NEXT X
8470 PRINT TAB(10)H$(J):PRINT TAB(10)H2$(J)
8480 PRINT TAB(10)H1$(J):PRINT TAB(10)H3$(J)
8490 PRINT TAB(10)H4$(J):PRINT TAB(10)H5$(J):PRINT 
8495 PRINT TAB(10)H6$(J):PRINT TAB(10)H7$(J) :PRINT
8500 LINE INPUT "IS THIS CORRECT (Y OR N)  <Y>  ";X2$
8510 PRINT E$;"E":FOR X=1 TO 6:PRINT:NEXT X
8520 IF X2$="n" OR X2$="N" THEN 8280
8530 GOSUB 8610
8540 ' STORE NEW DATA
8550 OPEN "O",1,D$
8560 PRINT #1,R
8570 FOR I=1 TO R
8580 PRINT #1,C$;A$(I);C$;",";C$;A1$(I);C$;",";C$;A2$(I);C$;",";C$;A3$(I);C$;",";C$;A4$(I);C$;","C$;A5$(I);C$;",";C$;A6$(I);C$;","C$;A7$(I);C$
8590 NEXT I
8600 CLOSE #1:GOTO 140
8610 A$(J)=H$(J):A1$(J)=H1$(J):A2$(J)=H2$(J):A3$(J)=H3$(J):A4$(J)=H4$(J):A5$(J)=H5$(J):A6$(J)=H6$(J):A7$(J)=H7$(J):GOTO 8110
9000 PRINT E$;"E":PRINT :PRINT :PRINT :PRINT :PRINT
9010 OPEN "O",#2,"AT:"
9020 FOR I=1 TO R
9030 PRINT #2," ";A$(I);", ";A2$(I);TAB(35);" ";A1$(I);TAB(57);" ";A3$(I);
9033 PRINT TAB(75);" ";A4$(I);TAB(88);" ";A5$(I);TAB(96);" ";
9036 PRINT A6$(I);TAB(107);" ";A7$(I)
9040 NEXT I
9050 CLOSE
9060 GOTO 140
75);" ";A4$(I);TAB(88);" ";A5$(I);TAB(96);" ";
9036 PRINT A6$(I);TAB(107);" ";A7$(I)
9040 NEXT I
9050