home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / SIMTEL / CPMUG / CPMUG044.ARK / BUDGETCH.BAS < prev    next >
BASIC Source File  |  1984-04-29  |  4KB  |  108 lines

  1. REM                   BUDGETCH.BAS
  2. REM
  3. REM   This program is designed to make changes in erroneous entries
  4. REM   made with BUDGET1.BAS.  It works with a dual or single disc system
  5. REM   and CBASIC, version 2.
  6. REM
  7.       PRINT "THIS PROGRAM CORRECTS ENTRIES MADE WITH BUDGET1.BAS."
  8.       PRINT:PRINT:PRINT
  9. 10    INPUT "Name the file you are accessing:"; LINE RESP$
  10. REM   * *we check the file for a reasonable name* *
  11.       IF RESP$="" THEN GOTO 10
  12.       IF LEN(RESP$)>12 THEN PRINT "TOO LONG.":GOTO 10
  13.       TYPE$=RIGHT$(UCASE$(RESP$),4) REM check on last four letters .xxx
  14.       DOT$=LEFT$(TYPE$,1)
  15.       IF DOT$<>"." THEN PRINT "ERROR IN TYPE.":GOTO 10
  16.       FILE.NAME$=UCASE$(RESP$)
  17. REM   * *end of checking procedure* *
  18.       FALSE%=0
  19.       TRUE%=-1
  20.       DEF FN.GET.TO.END%(FILE.NOMBRE$,REC.SIZE%,FILE.NUM%,POSITION%)
  21.           FN.GET.TO.END%=FALSE%
  22.           FILE.SIZE%=SIZE(FILE.NOMBRE$)
  23.           IF FILE.SIZE%=0 THEN \  false if no file exists
  24.                 RETURN \
  25.                 ELSE FN.GET.TO.END%=TRUE%
  26.           IF END # FILE.NUM% THEN 15
  27.           POSITION%=INT%(FLOAT(FILE.SIZE%)*128/REC.SIZE%)
  28.           PRINT TAB(15); "locating end of file"
  29.           READ # FILE.NUM%,POSITION%;
  30.           WHILE TRUE%
  31.                READ # FILE.NUM%; LINE DUMMY$
  32.                POSITION%=POSITION%+1
  33.                WEND
  34. 15        FN.GET.TO.END%=POSITION%
  35.           RETURN
  36.       FEND       REM * *end of this function* *
  37.       POSN%=0
  38.       OPEN FILE.NAME$ RECL 64 AS 1   REM we see how big the file is
  39.       RECORD.NUMBER%=FN.GET.TO.END%(FILE.NAME$,64,1,POSN%)
  40.       M%=RECORD.NUMBER% -1    REM pointer ends one past end of records
  41.       CLOSE 1
  42. REM
  43.       DIM CAT$(M%,4)
  44.       DIM AMT(M%,4)
  45.       DIM PAYEE$(M%)
  46.       DIM DATE%(M%)
  47.       DIM TOTAL(M%)
  48.       DIM STATUS%(M%)
  49. 20    PRINT "We will now access records one by one and present them for your"
  50.       PRINT "inspection."
  51.       OPEN FILE.NAME$ RECL 64 AS 1
  52.            N%=1        REM index for the read # routine
  53.            WHILE TRUE%
  54.            IF END # 1 THEN 25
  55.            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)
  56.            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)
  57.            TOTAL(N%)=0
  58.            FOR K%=1 TO 4
  59.                 TOTAL(N%)=TOTAL(N%)+AMT(N%,K%)
  60.                 NEXT K%
  61.            PRINT TAB(25);"<cr> if this is OK; if not, type 'N':":INPUT LINE OK$
  62.            IF OK$="N" THEN STATUS%(N%)=0  ELSE STATUS%(N%)=-1
  63.            N%=N%+1 REM index to help us get back to correct record
  64.            IF N%>M% THEN GOTO 25
  65.            WEND
  66.   
  67. 25    REM  We have gotten all records out of the file, now we need to locate
  68.       REM  the errors and correct them in the memory; then put back the file.
  69.       
  70.       FOR K%=1 TO (N%-1)
  71.         WHILE NOT STATUS%(K%)
  72. 30              PRINT DATE%(K%);" ";PAYEE$(K%);":"
  73.                 FOR L%=1 TO 4
  74.                      PRINT CAT$(K%,L%);" ";"$";AMT(K%,L%)
  75.                      NEXT L%
  76.                 PRINT "enter correct data for all 10 fields:"
  77.                 INPUT "correct date:"; DATE%(K%)
  78.                 INPUT "correct Payee:"; PAYEE$(K%)
  79.                 TOT=0
  80.                 FOR L%=1 TO 4
  81.                      PRINT "category (";L%;"):":INPUT LINE CAT$(K%,L%)
  82.                      PRINT "amount (";L%;"):$":INPUT AMT(K%,L%)
  83.                      TOT=TOT+AMT(K%,L%)
  84.                      NEXT L%
  85.                 IF TOT<>TOTAL(K%) THEN PRINT "New total not equal to old."
  86.                 PRINT "<cr> if no mistakes were made in this entry."
  87.                 INPUT LINE R$  
  88.                 IF R$<>"" THEN GOTO 30
  89.                 PRINT "corrected amounts entered into memory."
  90.                 STATUS%(K%)=-1
  91.                 WEND
  92.         NEXT K%
  93. REM
  94. REM  corrected data is now entered back onto the disc
  95. REM
  96.      CLOSE 1
  97.      CREATE FILE.NAME$ RECL 64 AS 1
  98.      FOR K%=1 TO (N%-1)
  99.           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)
  100.           PRINT PAYEE$(K%);" information entered onto disc."
  101.           NEXT K%
  102.      CLOSE 1
  103.      PRINT (N%-1);" records have been entered to the disc."
  104.      PRINT "Any more files to be corrected? [YES=1,NO=0] :"
  105.      INPUT REPEAT%
  106.      IF REPEAT% THEN GOTO 10 ELSE PRINT TAB(25);"Adios!"
  107. END
  108. EOF