REM BUDGETCH.BAS REM REM This program is designed to make changes in erroneous entries REM made with BUDGET1.BAS. It works with a dual or single disc system REM and CBASIC, version 2. REM PRINT "THIS PROGRAM CORRECTS ENTRIES MADE WITH BUDGET1.BAS." PRINT:PRINT:PRINT 10 INPUT "Name the file you are accessing:"; LINE RESP$ REM * *we check the file for a reasonable name* * IF RESP$="" THEN GOTO 10 IF LEN(RESP$)>12 THEN PRINT "TOO LONG.":GOTO 10 TYPE$=RIGHT$(UCASE$(RESP$),4) REM check on last four letters .xxx DOT$=LEFT$(TYPE$,1) IF DOT$<>"." THEN PRINT "ERROR IN TYPE.":GOTO 10 FILE.NAME$=UCASE$(RESP$) REM * *end of checking procedure* * FALSE%=0 TRUE%=-1 DEF FN.GET.TO.END%(FILE.NOMBRE$,REC.SIZE%,FILE.NUM%,POSITION%) FN.GET.TO.END%=FALSE% FILE.SIZE%=SIZE(FILE.NOMBRE$) IF FILE.SIZE%=0 THEN \ false if no file exists RETURN \ ELSE FN.GET.TO.END%=TRUE% IF END # FILE.NUM% THEN 15 POSITION%=INT%(FLOAT(FILE.SIZE%)*128/REC.SIZE%) PRINT TAB(15); "locating end of file" READ # FILE.NUM%,POSITION%; WHILE TRUE% READ # FILE.NUM%; LINE DUMMY$ POSITION%=POSITION%+1 WEND 15 FN.GET.TO.END%=POSITION% RETURN FEND REM * *end of this function* * POSN%=0 OPEN FILE.NAME$ RECL 64 AS 1 REM we see how big the file is RECORD.NUMBER%=FN.GET.TO.END%(FILE.NAME$,64,1,POSN%) M%=RECORD.NUMBER% -1 REM pointer ends one past end of records CLOSE 1 REM DIM CAT$(M%,4) DIM AMT(M%,4) DIM PAYEE$(M%) DIM DATE%(M%) DIM TOTAL(M%) DIM STATUS%(M%) 20 PRINT "We will now access records one by one and present them for your" PRINT "inspection." OPEN FILE.NAME$ RECL 64 AS 1 N%=1 REM index for the read # routine WHILE TRUE% IF END # 1 THEN 25 READ # 1,N%;DATE%(N%),PAYEE$(N%),CAT$(N%,1),AMT(N%,1),CAT$(N%,2),AMT(N%,2),CAT$(N%,3),AMT(N%,3),CAT$(N%,4),AMT(N%,4) PRINT DATE%(N%);PAYEE$(N%);":";CAT$(N%,1);AMT(N%,1);CAT$(N%,2);AMT(N%,2);CAT$(N%,3);AMT(N%,3);CAT$(N%,4);AMT(N%,4) TOTAL(N%)=0 FOR K%=1 TO 4 TOTAL(N%)=TOTAL(N%)+AMT(N%,K%) NEXT K% PRINT TAB(25);" if this is OK; if not, type 'N':":INPUT LINE OK$ IF OK$="N" THEN STATUS%(N%)=0 ELSE STATUS%(N%)=-1 N%=N%+1 REM index to help us get back to correct record IF N%>M% THEN GOTO 25 WEND 25 REM We have gotten all records out of the file, now we need to locate REM the errors and correct them in the memory; then put back the file. FOR K%=1 TO (N%-1) WHILE NOT STATUS%(K%) 30 PRINT DATE%(K%);" ";PAYEE$(K%);":" FOR L%=1 TO 4 PRINT CAT$(K%,L%);" ";"$";AMT(K%,L%) NEXT L% PRINT "enter correct data for all 10 fields:" INPUT "correct date:"; DATE%(K%) INPUT "correct Payee:"; PAYEE$(K%) TOT=0 FOR L%=1 TO 4 PRINT "category (";L%;"):":INPUT LINE CAT$(K%,L%) PRINT "amount (";L%;"):$":INPUT AMT(K%,L%) TOT=TOT+AMT(K%,L%) NEXT L% IF TOT<>TOTAL(K%) THEN PRINT "New total not equal to old." PRINT " if no mistakes were made in this entry." INPUT LINE R$ IF R$<>"" THEN GOTO 30 PRINT "corrected amounts entered into memory." STATUS%(K%)=-1 WEND NEXT K% REM REM corrected data is now entered back onto the disc REM CLOSE 1 CREATE FILE.NAME$ RECL 64 AS 1 FOR K%=1 TO (N%-1) PRINT # 1;DATE%(K%),PAYEE$(K%),CAT$(K%,1),AMT(K%,1),CAT$(K%,2),AMT(K%,2),CAT$(K%,3),AMT(K%,3),CAT$(K%,4),AMT(K%,4) PRINT PAYEE$(K%);" information entered onto disc." NEXT K% CLOSE 1 PRINT (N%-1);" records have been entered to the disc." PRINT "Any more files to be corrected? [YES=1,NO=0] :" INPUT REPEAT% IF REPEAT% THEN GOTO 10 ELSE PRINT TAB(25);"Adios!" END