REM             ** CDAILY **
REM   DAILY CHECK BOOK RECORD
REM      PRINTS OUT TO PRINTER OR CONSOLE THE DAILY BALANCE OF THE CHECK\
         BOOK.    BY CHRIS KOVACS  JUNE 30, 1982
REM	***VERSION 1.4***   JULY 28, 1982
REM \
	***VERSION 1.5*** OCTOBER 23, 1982\
	ADDS NEW FILE NAMES  -- FILENAME.CHK ---

	MT%=80 
	DIM PY$(MT%), CN(MT%), DT(MT%), AM(MT%)
5	NA%=0 : PL%=1 : CB=0 : BB=0
	PRINT CHR$(26)
	GOTO 10
8	PRINT "FILE DOES NOT EXIST"
10	INPUT "ENTER THE MONTH OF THE DESIRED CHECK BOOK FILE -- "; F$
	INPUT "DO YOU WANT A PRINT OUT?"; A$
	IF MID$(A$,1,1)="Y" THEN POUT=1 : GOTO 20
	POUT=2
20	IF F$="END" THEN STOP
	PRINT CHR$(26)

	IF END #1 THEN 8
    REM  OPEN DISK FILE AND READ

	OPEN F$+".CHK" AS 1
	FOR EP% = 0 TO MT%
		READ #1; CN(EP%), DT(EP%), AM(EP%), PY$(EP%)
		IF CN(EP%) <> 0 THEN \
	NEXT
	CLOSE 1
	NA%=EP%

    REM SORT ROUTINE

	EP%=0 : GOSUB 500 : REM PRINT OUT OF INIT. BAL.
	T1=800000 : LP%=1
50	T2=999999
	FOR EP% = 1 TO NA%-1
	IF DT(EP%)>=T1 AND DT(EP%)<T2 THEN T2=DT(EP%) : T3=EP%
	NEXT
	IF T2=999999 THEN 1000
	EP%=T3
	GOSUB 500
	DT(EP%)=0
	T1=T2
	IF LP%=22 AND POUT=2 THEN\
	      INPUT "CONTINUE? "; LINE A$ : LP%=1
	IF LP%=55 AND POUT=1 THEN PRINT CHR$(12) : LP%=1
	GOTO 50

    REM PRINT OUT RECORD

500	IF CN(EP%)<>0 THEN CB=CB+AM(EP%)
	IF CN(EP%)<0 THEN BB=BB+AM(EP%)
	IF POUT=1 THEN LPRINTER
	PRINT ABS(CN(EP%)); TAB(8);
	I=DT(EP%)/10000 : J=(I-INT(I))*100 : K=(J-INT(J))*100
	PRINT INT(J+.1);"/";INT(K+.1);"/";INT(I+.1);
	PRINT TAB(22);CHR$(68+(AM(EP%)<0)); TAB(26);
	PRINT PY$(EP%); TAB(50);
	X=ABS(AM(EP%))
	FOR$ = "$$#,###.##"
	PRINT USING FOR$; X;
	PRINT TAB (60);
	IF CN(EP%)>0 THEN 550
	PRINT "CLRD";
550	PRINT TAB(65); "//";
	PRINT USING FOR$; CB
	LP%=LP%+1
	RETURN

1000	CONSOLE
	PRINT
	INPUT "DO YOU WANT ANOTHER DAILY RECORD? "; A$
	IF MID$(A$,1,1)="Y" THEN 5
	CHAIN "CMENU"
	END 
LE
	PRINT
	INPUT "DO YOU WANT ANOTHER DAILY RECORD? "; A$
	IF MID$(A$,1,1)="Y" THEN 5
	CHAIN "CMENU"
	END 
