138 FIELD #1,20 AS F0$,30 AS F1$,3 AS LT$,3 AS LE$,2 AS LP$,2 AS PC$,2 AS PP$,2 AS PI$,2 AS MR$,2 AS DR$:GET 1,1:CN$=F0$:CA$=F1$:LS$=LT$:LD$=LE$:LP=CVI(LP$):PC%=CVI(PC$):PP%=CVI(PP$):PI%=CVI(PI$):MR%=CVI(MR$):DR%=CVI(DR$):RETURN
140 FIELD #1,20 AS F0$,30 AS F1$,3 AS LT$,3 AS LE$,2 AS LP$, 2 AS PC$,2 AS PP$,2 AS PI$,2 AS MR$,2 AS DR$: LSET F0$=CN$:LSET F1$=CA$:LSET LT$=LS$:LSET LE$=LD$: LSET LP$=MKI$(LP):LSET PC$=MKI$(PC%):LSET PP$=MKI$(PP%): LSET PI$=MKI$(PI%)
142 LSET MR$=MKI$(MR%):LSET DR$=MKI$(DR%): PUT 1,1:RETURN
144 FIELD #3,2 AS JP$:RETURN
146 RETURN
148 RETURN
150 RETURN
152 RETURN
154 FOR Z8=1 TO 900:NEXT Z8:RETURN
200 REM --------------------KEYBOARD ENTRY ROUTINE----------------------------
202 A$=INKEY$:A1$=""
204 A$=INKEY$:IF A$="" THEN 204 ELSE IF A$=CHR$(13) THEN RETURN
206 IF A$="@" THEN A1$=A$:RETURN ELSE IF A$=CHR$(127) THEN A$=CHR$(8)
208 IF ASC(A$)=ASC("L")-64 THEN A1$=A$:RETURN
210 IF A$=PRIN$ THEN 218
212 IF (A$<>CHR$(8) AND ASC(A$)<32) THEN A1$=A$:RETURN
214 IF LEN(A1$)>0 AND A$=CHR$(8) THEN A1$=LEFT$(A1$,LEN(A1$)-1):PRINT A$;:GOTO 204 ELSE IF LEN(A1$)=0 AND A$=CHR$(8) THEN 204
216 A1$=A1$+A$:PRINT A$;:A$="":GOTO 204
218 IF PRIN% THEN PRIN%=0:PRINT FNC$(1,0);SPC(2);:GOTO 222
220 IF NOT(PRIN%) THEN PRIN%=-1:PRINT FNC$(1,0);CHR$(27);CHR$(41);"^P";CHR$(27);CHR$(40);
222 PRINT FNC$(9,23);
224 '
226 GOTO 202
300 REM ---------------------MAIN DATA-ENTRY SCREEN---------------------------
306 GOSUB 2002:IF TGT$="?" THEN GOSUB 1002:GOTO 302 ELSE IF TGT$="*" THEN 802 ELSE IF TGT$="@" THEN 306 ELSE IF ASC(TGT$)=ASC("L")-64 THEN 2102
308 IF (TGT$=CHANGE$ AND DISFLAG=1) THEN GOSUB 402:GOSUB 120:GOSUB 132:GOTO 306 ELSE IF (TGT$=DELE$ AND DISFLAG=1) THEN GOSUB 460:GOTO 302 ELSE IF TGT$=CLEARW$ THEN DISFLAG=0:GOTO 302
310 IF TGT$=REINDEX$ THEN GOSUB 1302:GOSUB 602:DISFLAG=0:GOTO 302 ELSE IF TGT$=SORT$ THEN GOSUB 502:DISFLAG=0:GOTO 302
312 IF (TGT$=BACK$ OR TGT$=SKIPB$ OR TGT$=FORWARD$ OR TGT$=SKIPF$) AND DISFLAG=1 THEN GOSUB 924:GOSUB 1602:TGT$=W0$:GOTO 306
314 IF (TGT$=FIRST$ OR TGT$=LAST$ OR TGT$="." OR (VAL(TGT$)>0 AND VAL(TGT$)<=KP%)) THEN GOSUB 924:GOSUB 1602:DISFLAG=1:TGT$=W0$:GOTO 306
316 IF BY=1 THEN W0$=F0$:GOSUB 1602:DISFLAG=1:GOTO 306 ELSE DISFLAG=0:W0$=TGT$
318 CF#=0#:TF#=0#:SF#=0#:PRINT FNC$(11,23);
320 GOSUB 202:W1$=A1$:IF LEFT$(W1$,1)=CLEARW$ THEN DISFLAG=0:GOTO 302
322 BY=255:PRINT FNC$(13,23);:GOSUB 202:W2$=A1$:IF W2$=CLEARW$ THEN DISFLAG=0:GOTO 302
324 PRINT FNC$(15,23);:GOSUB 202:W3$=A1$:IF W3$=CLEARW$ THEN DISFLAG=0:GOTO 302
326 PRINT FNC$(17,23);:GOSUB 202:W6$=A1$:IF W6$=CLEARW$ THEN DISFLAG=0:GOTO 302
522 IF MID$(S1$,SP,NK)+S1$<=MID$(S2$,SP,NK)+S2$ THEN 532
524 LSET F$=S1$:PUT 1,L+1:LSET F$=S2$:PUT 1,I+1
526 I=I-M
528 IF I<1 THEN 532
530 GOTO 514
532 J=J+1
534 IF J>K THEN 506
536 GOTO 512
538 I=KP%:GET 1,I:MID$(S1$,1,RL%)=F$
540 IF MID$(S1$,31,3)="***" THEN KP%=KP%-1:GOTO 538
542 LSET KP$=MKI$(KP%):PUT 2,1
544 LSET YT$=MKI$(KP%):PUT 3,1
546 PRINT STRING$(25,7);:GOTO 602
600 REM ----------------------------REKEY INDEX-------------------------------
602 GOSUB 112
604 PRINT FNC$(23,0);"RE-INDEXING ";KP%-1;" KEY RECORDS ON *** NAME ***"
606 LSET KP$=MKI$(-1):FOR PR%=1 TO MK%:PUT 2,PR%:NEXT PR%:LSET KP$=MKI$(KP%):PUT 2,1:PRINT CHR$(7);:FOR PR%=2 TO KP%:PRINT FNC$(22,75);PR%-1;
608 GOSUB 128:GOSUB 116:ZZ$=W0$
610 GOSUB 1102:IF RP>MK% OR RP<2 THEN RP=2
612 GET 2,RP
614 IF LEFT$(W1$,3)="***" THEN LSET KP$=MKI$(-PR%):PUT 2,RP:GOTO 620
616 IF CVI(KP$)>0 THEN RP=RP+1:GOTO 612
618 LSET KP$=MKI$(PR%):PUT 2,RP
620 NEXT PR%:GOTO 652
622 REM
624 RETURN
650 REM -----------REKEY CATEGORY INDEX----------
652 GOSUB 112
654 PRINT FNC$(23,0);"RE-INDEXING ";KP%-1;" KEY RECORDS ON *** CATEGORY ***"
656 LSET YT$=MKI$(-1):FOR PR%=1 TO MK%:PUT 3,PR%:NEXT PR%:LSET YT$=MKI$(KP%):PUT 3,1:PRINT CHR$(7);:FOR PR%=2 TO KP%:PRINT FNC$(22,75);PR%-2;
658 GOSUB 128:GOSUB 116:YY$=W4$
660 GOSUB 1152:IF RY>MK% OR RY<2 THEN RY=2
662 GET 3,RY
664 IF LEFT$(W1$,3)="***" THEN LSET YT$=MKI$(-PR%):PUT 3,RY:GOTO 670
666 IF CVI(YT$)>0 THEN RY=RY+1:GOTO 662
668 LSET YT$=MKI$(PR%):PUT 3,RY
670 NEXT PR%:GOSUB 140:TOGGLE=0:PRINT CHR$(7);:GOTO 302
700 REM ----------------------INITIALISE NEW FILE-----------------------------
702 GOSUB 1302:PRINT
704 YN$="Y":GOSUB 1220:GOSUB 112:PRINT "NEW FILE":PRINT STRING$(SY%/3,10);:INPUT "YOUR COMPANY NAME (MAX=20) ";CN$:IF CN$="*" THEN CLOSE:CLEAR:RUN
706 INPUT "ADDRESS AS 1 LINE (MAX=30) ";CA$
708 LS$="":LD$="":FOR I=1 TO 3:LS(I)=0:LD(I)=0:NEXT I:T=1
710 LS$=STRING$(3,0)
712 '
714 LD$=STRING$(3,0)
716 '
718 INPUT "PRT PAGE LENGTH IN LINES ";LP
720 INPUT "MAXIMUM NUMBER OF RECORDS (1000-20000) ";MR%:IF MR%<1000 OR MR%>20000 THEN 720 ELSE MK%=MR%+INT(MR%/2)
722 PI%=0:PP%=0:PC%=0
724 PR%=1:PRINT:INPUT "DETAILS OK (.Y/N) ";YN$:IF YN$="" THEN YN$="Y" ELSE YN$=CHR$(ASC(YN$) AND 95)
726 IF YN$<>"Y" THEN 702
728 FIELD #1,20 AS F0$,30 AS F1$,3 AS LT$,3 AS LE$,2 AS LP$,2 AS PI$,2 AS PC$,2 AS PP$,2 AS MR$,2 AS DR$:LSET F0$=CN$:LSET F1$=CA$:LSET LT$=LS$:LSET LE$=LD$:LSET LP$=MKI$(LP):LSET PI$=MKI$(PI%):LSET PC$=MKI$(PC%):LSET PP$=MKI$(PP%)
730 LSET MR$=MKI$(MR%):LSET DR$=MKI$(0):PUT 1,1
732 FIELD #2,2 AS KP$:LSET KP$=MKI$(-1)
734 FOR I=1 TO MK%:PUT 2,I:NEXT I:LSET KP$=MKI$(1):PUT 2,1
736 FIELD #3,2 AS YT$:LSET YT$=MKI$(-1)
738 FOR I=1 TO MK%:PUT 3,I:NEXT I:LSET YT$=MKI$(1):PUT 3,1
740 CLOSE:GOTO 20
798 REM =======================GENERAL SUB-ROUTINES===========================
800 REM -------------------------PROGRAM EXIT SCREEN--------------------------
802 GOSUB 1302:PRINT FNC$(12,0);;"THANK YOU FOR USING MICROFLEX 'ADDRESS FILE' ";FNC$(20,0);"WAIT FOR >OK BEFORE SWITCHING OFF":GOSUB 140:CLOSE:END
900 REM ------------------------KEYBOARD INPUT OF KEY-------------------------
902 GOSUB 1420
904 PRINT FNC$(9,23);:GOSUB 202:TGT$=A1$:IF TGT$="*" THEN RETURN ELSE IF TGT$="?" THEN RETURN ELSE IF TGT$="@" THEN TOGGLE=1:RETURN
906 IF (VAL(TGT$)>0 AND VAL(TGT$)<=KP%) THEN PR%=VAL(TGT$)+1:GOSUB 128:GOSUB 116:TGT$=W0$:P1=1:GOTO 918
908 IF (ASC(TGT$)<32 OR TGT$=".") THEN RETURN
910 ZZ$=LEFT$(TGT$+STRING$(30,32),30):GOSUB 1102:IF RP>MK% OR RP<2 THEN RP=2
912 KQ%=RP:GET 2,RP:PR%=CVI(KP$):IF KP%<2 THEN PR%=2:BY=0:RETURN ELSE IF PR%<0 THEN PR%=KP%+1:BY=0:PRINT FNC$(1,35);"NOT FOUND";:RETURN
914 P1=0:IF PR%<=KP% THEN GOSUB 128:GOSUB 116:P1=INSTR(W0$,TGT$) ELSE GOTO 920
916 IF P1=0 THEN RP=RP+1:GOTO 912 ELSE IF (LEFT$(W1$,3)="***" AND INSTR(W0$,TGT$)>0) THEN PRINT "///DELETED RECORD///":BY=0:RETURN
918 IF P1=1 THEN YN$="Y":BY=1:W0$=TGT$:RETURN
920 IF P1=0 THEN BY=9:GOSUB 154:RETURN
922 KQ%=RP:BY=1:RETURN
924 IF TGT$=BACK$ THEN PR%=PR%-1:GOTO 928 ELSE IF TGT$=FORWARD$ THEN PR%=PR%+1:GOTO 928 ELSE IF TGT$=SKIPB$ THEN PR%=PR%-10:GOTO 928 ELSE IF TGT$=SKIPF$ THEN PR%=PR%+10:GOTO 928
926 IF TGT$=FIRST$ THEN PR%=2 ELSE IF TGT$=LAST$ THEN PR%=KP% ELSE IF TGT$="." THEN PR%=LSTREC%+1 ELSE IF VAL(TGT$)>0 AND VAL(TGT$)<=KP% THEN PR%=VAL(TGT$)
928 IF PR%>KP% THEN PR%=KP% ELSE IF PR%<2 THEN PR%=2
930 P1=0:IF PR%<=KP% THEN GOSUB 128:GOSUB 116:P1=0
932 IF P1>0 AND (TGT$=FORWARD$ OR TGT$=SKIPF$ OR TGT$=LAST$) THEN PR%=PR%+1:GOTO 928 ELSE IF P1>0 AND (TGT$=BACK$ OR TGT$=SKIPB$ OR TGT$=FIRST$) THEN PR%=PR%-1:GOTO 928
934 GOSUB 128:GOSUB 116
936 RETURN
938 YY$=W4$:GOSUB 1152
940 GET 3,RY:IF CVI(YT$)>0 THEN RY=RY+1:GOTO 940
942 LSET YT$=MKI$(PR%):PUT 3,RY
944 RETURN
1000 REM -------------------------PRINT '?' LISTING---------------------------
1002 I8%=-1:GOSUB 112:GOSUB 1302:PRINT:FOR I9%=2 TO KP%:GET 1,I9%:GOSUB 116
1004 IF LEFT$(W1$,3)<>"***" THEN I8%=I8%+1:PRINT TAB(40*I8%);I9%;W0$;W1$;
1006 IF I8%=1 THEN I8%=-1
1008 NEXT I9%:PRINT:PRINT:INPUT "PRESS <ENTER> TO CONTINUE ";YN$:RETURN
1100 REM -----------------------------HASHING ALGORITHM-----------------------
1226 IF D5>31 THEN D6=D6+1:D5=D5-31:GOTO 1226 ELSE T$=MID$(STR$(D6),2):T$=RIGHT$("00"+T$,2):DA$="/"+T$+DA$:T$=MID$(STR$(D5),2):T$=RIGHT$("00"+T$,2):DA$=T$+DA$
1228 RETURN
1300 REM --------------------------SCREEN HEADER-----------------------------
1302 PRINT CLS$:PRINT FNC$(2,0);STRING$(20,46);"M.U.G.W.A. PUBLIC DOMAIN ADDRESS FILE";STRING$(21,46)
1304 PRINT STRING$(SX%,46);:IF PRIN% THEN PRINT FNC$(1,0);CHR$(27);CHR$(41);"^P";CHR$(27);CHR$(40); ELSE PRINT FNC$(1,0);SPC(2);
1306 PRINT FNC$(4,0);:RETURN
1400 REM -----------------------PRESS <RETURN> PROMPTS----------------------
1402 INPUT "1=print LABELS 2=print ADDRESS BOOK 3=QUIT (.1/2/3) ";LB$:IF LB$="" THEN LB$="1" ELSE IF INSTR("123",LB$)=0 THEN LB$="3"
1404 IF LB$="1" THEN INPUT "<C>ount or <P>rint (C/.P) ";CP$:IF CP$="" THEN CP$="P" ELSE CP$=CHR$(ASC(CP$) AND 95)
1406 RETURN
1408 INPUT "Set printer to top of form, then press <RETURN>...";YN$
1410 RETURN
1412 INPUT "Set printer to top of new label, then press <RETURN>...";YN$
1700 REM -----------------------------ERROR TRAP------------------------------
1702 PRINT "ERROR";ERR;"IN LINE ";ERL
1704 RESUME 1706
1706 CLOSE:END
1800 REM -------------------------get record by category----------------------
1802 GOSUB 1420
1804 PRINT FNC$(19,23);:GOSUB 202:TGT$=A1$:IF TGT$="*" THEN RETURN ELSE IF TGT$="?" THEN RETURN ELSE IF TGT$="@" THEN TOGGLE=0:RETURN ELSE IF TGT$=PRIN$ THEN TOGGLE=0:RETURN
1806 IF TGT$=REINDEX$ THEN RETURN
1808 IF (TGT$=CHANGE$ OR TGT$=DELE$ OR TGT$=CLEARW$ OR TGT$=SORT$) THEN TOGGLE=0:RETURN
1810 IF (TGT$=BACK$ OR TGT$=FORWARD$ OR TGT$=FIRST$ OR TGT$=LAST$) THEN TOGGLE=0:RETURN
1812 IF (TGT$=SKIPB$ OR TGT$=SKIPF$) THEN TOGGLE=0:RETURN
1814 YY$=LEFT$(TGT$+STRING$(8,"0"),8):GOSUB 1152:IF RY>MK% OR RY<2 THEN RY=2
1816 KQ%=RY:GET 3,RY:PR%=CVI(YT$):IF KP%<2 THEN PR%=2:BY=0:RETURN ELSE IF PR%<0 THEN PR%=KP%+1:BY=0:PRINT FNC$(1,35);"NOT FOUND";:DISFLAG=0:TOGGLE=0:RETURN
1818 P1=0:IF PR%<=KP% THEN GOSUB 128:GOSUB 116:P1=INSTR(W4$,TGT$) ELSE 1824
1820 IF P1=0 THEN RY=RY+1:GOTO 1816 ELSE IF (LEFT$(W1$,3)="***" AND INSTR(W4$,TGT$)>0) THEN PRINT "///DELETED RECORD///":BY=0:RETURN
1822 IF P1=1 THEN GOSUB 1902:IF YN$="Y" THEN DISFLAG=0:BY=1:TOGGLE=0:RETURN ELSE RY=RY+1:GOTO 1816
1824 IF P1=0 THEN BY=9:GOSUB 154:TOGGLE=0:RETURN
1826 KQ%=RY:BY=1:TOGGLE=0:RETURN
1900 REM ---------------------------IS THIS THE ONE ??-----------------------
1902 R=23:C=33:GOSUB 1602:PRINT FNC$(23,0);"Is this the one requested (.Y/N) ";:GOSUB 202:YN$=A1$:IF YN$="" OR YN$=CHR$(13) THEN YN$="Y" ELSE YN$=CHR$(ASC(YN$) AND 95)
1904 PRINT FNC$(23,0);CHR$(27)+"Y";
1906 RETURN
2000 REM ---------------------------ADJUST TOGGLE FOR KEY FIELD--------------
2002 IF TOGGLE=0 THEN 902 ELSE IF TOGGLE=1 THEN 1802 ELSE TOGGLE=0:GOTO 902
2004 IF BY=99 THEN 302
2100 REM ........................PRINT LABELS..................................
2102 LB$="":CP$="":GOSUB 1302:PRINT FNC$(12,0);:GOSUB 1402:IF (LB$="1" AND CP$="C") THEN 2152 ELSE IF LB$="1" THEN GOSUB 1412 ELSE IF LB$="2" THEN GOSUB 1408 ELSE GOTO 302
2104 IF LB$="2" THEN GOTO 2200 ELSE IF LB$="3" THEN 302
2300 REM .................DETERMINE STATE FROM POSTCODE........................
2302 IF (ST>=2000 AND ST<=2599) OR (ST>=2621 AND ST<=2899) THEN ST$="NSW":RETURN
2304 IF (ST>=2600 AND ST<=2620) OR (ST>=2900 AND ST<=2949) THEN ST$="ACT":RETURN
2306 IF (ST>=3000 AND ST<=3999) THEN ST$="VIC":RETURN
2308 IF (ST>=4000 AND ST<=4899) THEN ST$="QLD":RETURN
2310 IF (ST>=5000 AND ST<=5749) THEN ST$="SA ":RETURN
2312 IF (ST>=5750 AND ST<=5799) THEN ST$="NT ":RETURN
2314 IF (ST>=6000 AND ST<=6799) THEN ST$="WA ":RETURN
2316 IF (ST>=7000 AND ST<=7499) THEN ST$="TAS":RETURN
2318 ST$=" ":RETURN
2400 REM ....................CHECK CATEGORY FOR MATCH..........................
2402 DX$=F4$:IF CAT$="~~~~~~~~" THEN CAT%=-1:RETURN ELSE IF CAT$=DX$ THEN CAT%=-1:RETURN
2404 FOR I=1 TO 8
2406 IF MID$(CAT$,I,1)="~" THEN MID$(DX$,I,1)="~":GOTO 2412
2408 IF I<6 THEN CT%=VAL(MID$(DX$,I,1)):CU%=VAL(MID$(CAT$,I,1)):GOSUB 2702:IF CT%=CU% THEN MID$(DX$,I,1)=MID$(CAT$,I,1)
2410 IF I=6 THEN I=7:CT%=VAL(MID$(DX$,6,2)):CU%=VAL(MID$(CAT$,6,2)):GOSUB 2702:IF CT%=CU% THEN MID$(DX$,6,2)=MID$(CAT$,6,2)
2412 NEXT I
2414 IF CAT$=DX$ THEN CAT%=-1 ELSE CAT%=0
2416 RETURN
2500 REM ....................GET CATEGORY FOR LABELS...........................
2502 INPUT "Enter category required (use ~ for don't care) ";CAT$:IF CAT$="" THEN CAT$="~~~~~~~~" ELSE CAT$=LEFT$(CAT$+"~~~~~~~~",8)
2504 IF CAT$="~~~~~~~~" THEN 2512
2506 FOR I=1 TO LEN(CAT$):C$=MID$(CAT$,I,1)
2508 IF INSTR("0123456789~",C$)=0 THEN I=LEN(CAT$):CAT%=999 ELSE CAT%=0
2510 NEXT I:IF CAT%=999 THEN 2502
2512 RETURN
2600 REM ..........................GET SORT FIELD..............................
2602 PRINT FNC$(8,0);"1 = NAME 2 = ADDRESS";FNC$(9,0);"3 = CITY 4 = POSTCODE";FNC$(10,0);"5 = CATEGORY * = QUIT ";:INPUT SC$
2604 IF INSTR("12345*",SC$)=0 THEN 2602
2606 IF SC$="1" THEN SP=1:NK=30 ELSE IF SC$="2" THEN SP=31:NK=25 ELSE IF SC$="3" THEN SP=56:NK=20 ELSE IF SC$="4" THEN SP=76:NK=6 ELSE IF SC$="5" THEN SP=94:NK=8 ELSE IF SC$="*" THEN 302
2608 RETURN
2700 REM ......................PART OF CATEGORY CHECK..........................
2702 IF (CT%/2)<>INT(CT%/2) THEN CT%=CT%-1:KJ(1)=1 ELSE KJ(1)=0
2704 IF (CT%-32)>=0 THEN CT%=CT%-32:KJ(6)=32 ELSE KJ(6)=0
2706 IF (CT%-16)>=0 THEN CT%=CT%-16:KJ(5)=16 ELSE KJ(5)=0
2708 IF (CT%-8)>=0 THEN CT%=CT%-8:KJ(4)=8 ELSE KJ(4)=0
2710 IF (CT%-4)>=0 THEN CT%=CT%-4:KJ(3)=4 ELSE KJ(3)=0
2712 IF (CT%-2)>=0 THEN CT%=CT%-2:KJ(2)=2 ELSE KJ(2)=0
2714 IF (CU%/2)<>INT(CU%/2) THEN CU%=CU%-1:KK(1)=1 ELSE KK(1)=0
2716 IF (CU%-32)>=0 THEN CU%=CU%-32:KK(6)=32 ELSE KK(6)=0
2718 IF (CU%-16)>=0 THEN CU%=CU%-16:KK(5)=16 ELSE KK(5)=0
2720 IF (CU%-8)>=0 THEN CU%=CU%-8:KK(4)=8 ELSE KK(4)=0
2722 IF (CU%-4)>=0 THEN CU%=CU%-4:KK(3)=4 ELSE KK(3)=0
2724 IF (CU%-2)>=0 THEN CU%=CU%-2:KK(2)=2 ELSE KK(2)=0
2726 KJ=0:CT%=-99:CU%=99
2728 KJ=KJ+1:IF ((KJ(KJ)+KK(KJ))>0 AND (KJ(KJ)=KK(KJ))) THEN CU%=CT%
2730 IF KJ<6 THEN 2728
2732 RETURN
2800 REM ........................PRINT COPY OF WINDOW..........................