	REM GNREPORT.BAS * PROGRAM
	REM              *
	REM 11 23 82     * J.BUTLER
	REM SYSTEM CONTROL PROGRAM NUMBER :
	REM FILES UNDER 'DBFM' CONTROL    :

	REM COMMONS GO HERE
	COMMON CLEAR$,NAME$,LINE$,DEMO$,CRSR$,FOCUS$,HIGH$,LOW$,PASSWORD$, \
	       DATE$,EOL$,CLRFORE$,ROWOFF,COLOFF,SCRPARA,CONT
	
	REM ADD HARD SCREEN FUNCTIONS HERE IF NECESSARY

	REM DIMENSIONS GO HERE
	DIM MONTHS$(12),MASK$(10)

	MONTHS$(1)="JANUARY":MONTHS$(2)="FEBRUARY":MONTHS$(3)="MARCH"
	MONTHS$(4)="APRIL":MONTHS$(5)="MAY":MONTHS$(6)="JUNE"
	MONTHS$(7)="JULY":MONTHS$(8)="AUGUST":MONTHS$(9)="SEPTEMBER"
	MONTHS$(10)="OCTOBER":MONTHS$(11)="NOVEMBER":MONTHS$(12)="DECEMBER"

	BLANK$="                             ":SCNO$="":ERR=5


7       REM OPEN PARTICULAR FILE HERE

        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$: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 LEN(RECEND$)=0 THEN GOSUB 13
	PRINT:RECEND=VAL(RECEND$)
	IF VAL(RECEND$)<>INT(VAL(RECEND$)) THEN 11
	COLUMN=4:ROW=22:GOSUB 10
	PRINT "DEPRESS 'RETURN' WHEN PRINTER IS READY";:Y%=CONCHAR%
	GOTO 15

13	RECEND%=5000
	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:GOTO 60

50	REC1=REC1+1: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(3);PRINT USING "##";VAL(STR$(A1$))
REM	SUBTOTAL=SUBTOTAL + ....
	M1=M1+1:GOTO 50

200	GOSUB 700:PRINT CHR$(12):CONSOLE:GOTO 11

500	REM PRINT HEADING INFO
	PRINT TAB(40-LEN(COMPANY$)/2);COMPANY$
	PRINT TAB(40-LEN(COMPANY$)/2));LINE$:PRINT TAB(110);DATE$
	M1=12: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	IF END #1 THEN 6000

1001    READ #1,REC1;A1$
	RETURN

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

9990    CLOSE 1
        PRINT LOW$;CLEAR$:STOP
 
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
