        REM NADMAIL.BAS   * PROGRAM TO PRINT NAME & ADDRESSES ON LABELS
        REM               * 2400
        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)
        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
        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 START-END ROUTINE HERE
        PRINT CLEAR$:PRINT TAB(40-LEN(NAME$)/2);NAME$
        PRINT TAB(40-LEN(NAME$)/2);LINE$
        PRINT TAB(2);"MAILING LABELS REPORT";TAB(62);"DATE:";DATE$:VV=7:GOSUB 8
        PRINT TAB(25);"STARTING RECORD NO:";:INPUT "";LINE START$
        IF START$="END" OR START$="STOP" THEN 9990
        IF LEN(START$)=0 OR START$="1" THEN START$="2"
        IF VAL(START$)=0 THEN 11
        PRINT:START=VAL(START$)
        IF VAL(START$)<>INT(VAL(START$)) THEN 11
        PRINT TAB(25);"ENDING   RECORD NO:";:INPUT "";LINE RECEND$
        IF ONCE=1 THEN RECEND$=STR$(RECEND):GOTO 11.5
        IF LEN(RECEND$)=0 THEN GOSUB 13:ONCE=1

11.5    PRINT:RECEND=VAL(RECEND$)
        IF VAL(RECEND$)<>INT(VAL(RECEND$)) THEN 11

12      COLUMN=14:ROW=21:GOSUB 10:PRINT EOS$;
        PRINT "DEPRESS 'RETURN' WHEN PRINTER IS READY";:Y%=CONCHAR%
        GOTO 15

13      RECEND%=0
        IF END #1 THEN 14
        FOR F%=14 TO 1 STEP-1
        READ #1,2^F%+RECEND%;LINE X$
        RECEND%=RECEND%+2^F%

14      NEXT F%
        RECEND$=STR$(RECEND%):RETURN

15      REM PRINT GENERATION HERE
        K1=1:M1=0:REC1=START:SUBTOTAL=0:GRANDTOTAL=0:LPRINTER

20      GOSUB 1000
        TEMP=LEN(CA$(1)+CA$(2)+CA$(3)+CA$(4)+CA$(5)+CA$(6))
        IF TEMP<1 THEN 50
        GOTO 60

50      REC1=REC1+1
        IF REC1>RECEND THEN 200
        GOTO 20

60      IF M1>0 THEN 100
        GOSUB 500

100     REM PRINT ONE LINE ON SHEET
        IF M1>=55 THEN PRINT CHR$(12):GOSUB 500:M1=0
        PRINT TAB(2);CA$(1):PRINT TAB(2);CA$(2)
        IF LEN(CA$(3))=0 THEN 110
        PRINT TAB(2);CA$(3)

110     TEMP$=CA$(4)+", "+CA$(5)+". "+CA$(6)
        PRINT TAB(2);TEMP$
        IF LEN(CA$(3))=0 THEN PRINT
REM     SUBTOTAL=SUBTOTAL + ....
        PRINT:PRINT:M1=6:GOTO 50

200     CONSOLE:GOTO 11

500     REM PRINT HEADING INFO
        M1=1:RETURN

600     REM SUBTOTAL ROUTINE
        IF SUBTOTAL=0 THEN RETURN
        PRINT TAB(114);"SUBTOTAL";:PRINT USING S4$;ABS(SUBTOTAL)
        PRINT:PRINT:GRANDTOTAL=GRANDTOTAL+SUBTOTAL:M1=M1+5
        SUBTOTAL=0:RETURN

700     IF GRANDTOTAL=0 THEN RETURN
        PRINT:PRINT TAB(114);"GRANDTOTAL: ";
        PRINT USING S4$;ABS(GRANDTOTAL):GRANDTOTAL=0:RETURN

1000    ERR=5.2
        IF END #1 THEN 6000

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

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

8802    ROW=ROW-1:GOSUB 10:PRINT EOS$:RETURN

9990    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
