        REM NADSCRN.BAS   * PROGRAM TO SET UP NAME & ADDRESSES   *
        REM               * 2300
        REM 05 29 83      * J.BUTLER
        REM SYSTEM CONTROL PROGRAM NUMBER    :
 
        REM COMMONS GO HERE
        COMMON CLEAR$,NAME$,LINE$,DEMO$,CRSR$,EOL$,DATE$,ID$,SCRPARA,EOS$
        COMMON ROWOFF,COLOFF,DIO
 
        REM DIMENSIONS GO HERE
        DIM MONTHS$(12),CA$(10),CA(10)
        REV$="052983"
        BLANK$="........................................................":ERR=1
 
7       REM OPEN PARTICULAR FILE HERE
        ERR=5.1
        IF END #1 THEN 9992
        OPEN "NAD.FIL" RECL 224 AS 1
        REC1=0:GOSUB 1000:NEXTREC=VAL(CA$(2)):RECEND%=0
        IF NEXTREC=0 THEN NEXTREC=1
        IF END #1 THEN 7.5
        FOR F%=14 TO 1 STEP-1
        READ #1,2^F%+RECEND%;LINE X$
        RECEND%=RECEND%+2^F%

7.5     NEXT F%
        RECEND$=STR$(RECEND%):NEXTREC=RECEND%-1:GOTO 11
 
8       REM VERTICAL CURSOR POSITIONING ROUTINE
        FOR ZZ=1 TO VV:PRINT:NEXT ZZ:RETURN
 
9       REM DATE FORMATTING ROUTINE
        DATE$=MID$(P$,1,2)+"-"+MID$(P$,3,2)+"-"+MID$(P$,5,2)
        RETURN
 
10      REM CURSOR ADDRESS
        IF SCRPARA=1 THEN \
        PRINT CRSR$;CHR$(ROW+ROWOFF);CHR$(COLUMN+COLOFF);:RETURN
        PRINT CRSR$;CHR$(COLUMN+COLOFF);CHR$(ROW+ROWOFF);:RETURN

11      REM LENGTHS OF EACH FIELD
        CA(1)=30:CA(2)=30:CA(3)=30:CA(4)=20:CA(5)=2:CA(6)=9:CA(7)=6
        CA(8)=30:CA(9)=14:CA(10)=30

15      REM SCREEN GENERATION HERE
        PRINT CLEAR$:PRINT TAB(40-LEN(NAME$)/2);NAME$
        PRINT TAB(40-LEN(NAME$)/2);LINE$
        PRINT "  CLIENT # ";TAB(62);"DATE:";DATE$
        ROW=7:COLUMN=1:GOSUB 10:PRINT:REM 46+
        PRINT TAB(25);" 1. NAME           : "
        PRINT TAB(25);" 2. ADDRESS #1     : "
        PRINT TAB(25);" 3. ADDRESS #2     : "
        PRINT TAB(25);" 4. CITY           : "
        PRINT TAB(25);" 5. STATE          : "
        PRINT TAB(25);" 6. ZIP CODE       : "
        PRINT TAB(25);" 7. STARTUP DATE   : "
        PRINT TAB(25);" 8. COMPANY REPR.  : "
        PRINT TAB(25);" 9. TELEPHONE #    : "
        PRINT TAB(25);"10. MISCELLANEOUS  : "
        IF SECOND=1 THEN SECOND=0:RETURN

20      PRINT HIGH$;CLRFORE$;:HOLD$=STR$(REC1) 
        COLUMN=11:ROW=3:GOSUB 10:INPUT "";LINE RECORD$
        IF RECORD$="STOP" OR RECORD$="END" THEN 9990
        REC1=VAL(RECORD$)
        IF RECORD$="" THEN REC1=VAL(HOLD$)+1
        IF REC1>NEXTREC THEN 6000
 
25      PRINT CLRFORE$
        COLUMN=11:ROW=3:GOSUB 10:PRINT REC1:GOSUB 1000:GOSUB 60

30      PRINT LOW$;:COLUMN=11:ROW=22:GOSUB 10
        PRINT "IS THIS DATA CORRECT <Y/N> :";:Y%=CONCHAR%:GOSUB 10:PRINT EOL$;
        IF Y%=13 OR Y%=89 THEN 15

40      REM ERROR CHECKING STATEMENT HERE
        ROW=21:GOSUB 8802:RECUR$="":COLUMN=11:ROW=22:GOSUB 10
        PRINT EOL$;"'S'TOP, 'D'ELETE, 'R'ECUR @, FIELD #  :";
        INPUT "";LINE CHANGE$
        IF LEFT$(CHANGE$,1)="S" THEN GOSUB 2001:GOTO 9990
        IF CHANGE$="" THEN GOSUB 2001:SECOND=1:GOSUB 15:GOTO 20
        IF CHANGE$="D" THEN ONCE=1:X9=REC1+1:GOTO 8900
        IF MID$(CHANGE$,1,1)="R" THEN RECUR$="R" \
           :CHANGE$=MID$(CHANGE$,2,LEN(CHANGE$)-1)
        IF VAL(CHANGE$)=0 THEN 15
        NUM=10

50      IF VAL(CHANGE$)<1 OR VAL(CHANGE$)>NUM THEN 40
        GOSUB 7010
        IF RECUR$="R" AND VAL(CHANGE$)<=NUM THEN \
           CHANGE$=STR$(VAL(CHANGE$)+1):GOTO 50
        GOTO 40
        REM SECOND=1:GOSUB 15:GOSUB 2001:GOTO 25

60      REM SCREEN PRINT HERE
        COLUMN=46
        FOR X=1 TO 10
        ROW=7+X:GOSUB 10
        IF CA$(X)<>"" THEN PRINT CA$(X) ELSE PRINT LEFT$(BLANK$,CA(X))        
        NEXT X
        RETURN

1000    IF END #1 THEN 6000

1001    READ #1,REC1+1;CA$(1),CA$(2),CA$(3),CA$(4),CA$(5),CA$(6),CA$(7), \
                CA$(8),CA$(9),CA$(10) 
        RETURN

2001    PRINT #1,REC1+1;CA$(1),CA$(2),CA$(3),CA$(4),CA$(5),CA$(6),CA$(7), \
                CA$(8),CA$(9),CA$(10) 
REM     FOR X=1 TO 10:CA$(X)="":NEXT X
        RETURN

6000    COLUMN=2:ROW=21:GOSUB 10
        PRINT EOL$;"RECORD #";REC1;" HAS NOT BEEN ESTABLISHED ";CHR$(7);
        FOR X=1 TO 200:NEXT X

6010    GOSUB 8802:ROW=21:GOSUB 10
        PRINT EOS$;"DO YOU WANT TO CREATE THIS RECORD <Y/N> : ";:Y%=CONCHAR%
        IF Y%<>89 THEN GOSUB 10:PRINT EOL$:REC1=0:GOTO 20
        SECOND=1:GOSUB 8900:NEXTREC=REC1+6:GOTO 25

7010    REM SCREEN INPUT FUNCTIONS HERE
        Y$="":HOLDIT$=CA$(VAL(CHANGE$)):Y=1
        COLUMN=46:ROW=7+VAL(CHANGE$):GOSUB 10
        PRINT LEFT$(BLANK$,CA(VAL(CHANGE$))):GOSUB 10

7015    POKE DIO,0:CALL DIO+1
        CHR%=PEEK(DIO) AND 127
        IF CHR%=0 THEN 7015
        IF CHR%=8 AND LEN(Y$)<1 THEN 7015
        IF CHR%=27 THEN RECUR$="":RETURN
        IF CHR%=24 THEN 7010
        IF CHR%=13 THEN 7020
        IF CHR%=8  THEN Y$=LEFT$(Y$,LEN(Y$)-1):Y=Y-1:PRINT CHR$(8);" ";CHR$(8);
        IF CHR%<32 OR CHR%>122 THEN 7015
        IF Y>CA(VAL(CHANGE$)) THEN PRINT CHR$(7);:GOTO 7015
        PRINT CHR$(CHR%);:Y$=Y$+CHR$(CHR%):Y=Y+1:GOTO 7015

7018    CA$(VAL(CHANGE$))=HOLDIT$:RETURN

7020    IF Y$=" " THEN CA$(VAL(CHANGE$))="":RETURN
        IF Y$<>"" THEN CA$(VAL(CHANGE$))=Y$ ELSE CA$(VAL(CHANGE$))=HOLDIT$
        RETURN

8802    ROW=ROW-1:GOSUB 10:PRINT EOS$:RETURN
 
8900    REM DELETE RECORD FUNCTION HERE
        IF ONCE=1 THEN 8902
        FOR X9=REC1+1 TO REC1+6

8902    PRINT #1,X9;"","","","","","","","","",""
        IF ONCE=1 THEN ONCE=0:GOTO 8904
        NEXT X9

8904    IF SECOND=1 THEN SECOND=0:RETURN
        GOTO 15

9990    FOR X=1 TO 10:CA$(X)="":NEXT X
        CA$(2)=STR$(NEXTREC):REC1=0:GOSUB 2001:CLOSE 1
        PRINT LOW$;CLEAR$:CHAIN "NADMENU"
 
9992    FOR X=1 TO 24:PRINT:NEXT X
        PRINT TAB(20);"ACCESS NOT PERMITTED! SEE YOUR SYSTEM SUPERVISOR..";ERR;
        Y%=CONCHAR%
        IF Y%=5EH THEN 9999
        GOTO 9992
 
9999    PRINT LOW$;CLEAR$
        STOP

