***********************************************************
*
* FILE: B:NEWENTER
*
* ENTER NEW ITEMS IN CHECKBOOK
*
* DATE: 22-AUG-82

STORE 'V3.3' TO V:NEW

*
***********************************************************

GOTO BOTTOM
STORE 0 TO NAMECOUNT

*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<


DO WHILE T
ERASE

* INIT MEMORY VARIABLES ***********************************

STORE M:RNUM + 1 TO C:NUMBER
STORE ' ' TO C:CANCEL
STORE MM TO C:MM
STORE DD TO C:DD
STORE YY TO C:YY
STORE '                    ' TO C:NAME
STORE 0.00 TO C:AMOUNT
STORE 0 TO C:TYPECODE

* READ DATA ***********************************************

@ 5,10 SAY 'CHECK AND DEPOSIT ENTRY ' + V:NEW
@ 7,0  SAY 'ENTER TYPECODE OF 0 TO EXIT'
@ 8,0  SAY 'OLD BALANCE = '
@ 8,15 SAY M:OLDBAL
@ 10,0 SAY '      TYPECODE ' GET C:TYPECODE PICTURE '999'

READ

IF C:TYPECODE = 0 
	IF NAMECOUNT > 0
	DO B:PUTNAMES
	ENDIF
	RELEASE NAMECOUNT
	RETURN
ENDIF

IF C:TYPECODE < 100
	STORE T TO DEPOSIT
ELSE
	STORE F TO DEPOSIT
ENDIF


IF C:TYPECODE <= 130
	STORE 0 TO C:NUMBER
ENDIF

* DISPLAY AND GET REST OF DATA ITEM ***********************

@ 11,0  SAY '          NAME ' GET C:NAME
@ 12,0  SAY '        NUMBER ' GET C:NUMBER PICTURE '9999'
@ 13,16   GET C:MM PICTURE '99'
@ 13,20   GET C:DD PICTURE '99'
@ 13,24   GET C:YY PICTURE '99'
@ 13,0  SAY ' DATE = MMDDYY '
@ 14,0  SAY '        AMOUNT ' GET C:AMOUNT PICTURE '9999999.99'
@ 15,0  SAY '        CANCEL ' GET C:CANCEL

READ

* ERROR CHECKING ******************************************

STORE F TO M:ERROR

* SEE IF DUPLICATE CHECK NO. ******************************

IF C:NUMBER <> 0
	STORE STR(C:NUMBER,4) TO CNUM
	FIND &CNUM
	RELEASE CNUM
	IF #<>0
		STORE T TO M:ERROR
		? 'ERROR: DUP CHECK NO., REC NO.= ', #
	ENDIF
ENDIF


IF C:NAME = '                    '
	STORE T TO M:ERROR
	? 'ERROR: NAME MUST NOT BE BLANK'
ENDIF

IF C:NUMBER < 0
	STORE T TO M:ERROR
	? 'ERROR: NUMBER MUST BE >= 0'
ENDIF

IF C:MM <1 .OR. C:MM >12
	STORE T TO M:ERROR
	? 'ERROR: MM = ' + STR(C:MM,2)
ENDIF

IF C:DD <1 .OR. C:DD > 31
	STORE T TO M:ERROR
	? 'ERROR: DD = ' + STR(C:DD,2)
ENDIF

IF C:YY < 80 .OR. C:YY > 82
	STORE T TO M:ERROR
	? 'ERROR: YY = ' + STR(C:YY,2)
ENDIF

IF C:AMOUNT <=0
	STORE T TO M:ERROR
	? 'ERROR: AMOUNT MUST BE > 0'
ENDIF

IF C:TYPECODE <=0
	STORE T TO M:ERROR
	? 'ERROR: TYPECODE MUST BE > 0'
ENDIF

IF M:ERROR
  ? CHR(7)
  STORE 0 TO M:COUNT
  DO WHILE M:COUNT < 50
  STORE M:COUNT + 1 TO M:COUNT
  ENDDO
  RELEASE M:COUNT
ENDIF

* PUT NEW RECORD INTO DATA BASE ***************************

IF .NOT. M:ERROR

IF C:NAME = '.                   '
	STORE NAMECOUNT+1 TO NAMECOUNT
ENDIF

IF C:NUMBER <> 0
	STORE C:NUMBER TO M:RNUM
ENDIF

APPEND BLANK

REPLACE NUMBER WITH C:NUMBER, CANCEL WITH C:CANCEL
REPLACE DD WITH C:DD, MM WITH C:MM, YY WITH C:YY
REPLACE NAME WITH C:NAME, AMOUNT WITH C:AMOUNT
REPLACE TYPECODE WITH C:TYPECODE

IF DEPOSIT
	REPLACE BALANCE WITH M:OLDBAL + AMOUNT
ELSE
	REPLACE BALANCE WITH M:OLDBAL - AMOUNT
ENDIF
STORE BALANCE TO M:OLDBAL

ENDIF

********************************************

RELEASE M:ERROR, DEPOSIT

ENDDO

*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
