25 Years of Programming
An open source source for C, C++, OWL, BASIC, MDB, XLS, DOT, and more...
Home   Projects   Up   Sitemap   Search   Blog   Forum+Chat   About Us   Privacy   Terms of Use   Feedback   FAQ   Images   Services   Ads   Donate   Humor

Check ledger calculates category totals

CKLEDGER.BAS

This program is for situations where you have numeric amounts of any kind to post to different accounts or categories.  A typical use is to categorize and summarize the entries in a checkbook. The following description relates to that use.

You can define the categories that you want to use as you go along.  Be consistent with your category assignments and in spelling the names. First go down the check register, entering in order the category to which you want each check posted. Then, after entering '0' (zero) as the last entry, go back to the top of the list, and enter the amount of each check in the same order as you entered the categories. For each check, the program will prompt you with the name of the category you used, to help you keep your place in the list.

Let us assume you have the following checks in your checkbook:

Safeway $50.00
John Doe (landlord) $150.00
Safeway $50.00
John Doe (landlord) $150.00

A run of the program with these amounts will look like this:

Category: FOOD
Category: RENT
Category: FOOD
Category: RENT
Category: 0

The program will now ask for amounts, like this:

FOOD Amount? 50
RENT Amount? 150
FOOD Amount? 50
RENT Amount? 150
0    Amount? 0

The following output will be produced:

FOOD 100.00
RENT 300.00

Thus, your checks have been consolidated into the proper accounts.  Categories must be consistent. If you accidentally enter "FODO" instead of "FOOD", then you will have created a new category called "FODO".

Error recovery: each time you enter the number "-1", the computer backs up one entry. To go back to a line that is several lines previous to the one you are on, type "-1" to as many successive prompts as you need to.  Once you have backed up, you must re-input in forward order any lines that you passed over on your way backwards.

Other Version

Obviously, this was an early program for the H-89. There is a more modern and capable Microsoft Excel worksheet to do this at CHECKS.XLS. It works in conjunction with the Microsoft Access database EXPENSES.MDB.

 

10 REM CKLEDGER.BAS
11 'COPYRIGHT (C)1982 STEVEN WHITNEY.
12 'Initially published by http://25yearsofprogramming.com.
14 'Published under GNU GPL (General Public License) Version 2, with ABSOLUTELY NO WARRANTY.
20 ON ERROR GOTO 710
30 L$=STRING$(75,"-") : F$="#######.##": DEFINT I,J,K,P: DEFDBL A,T
40 PRINT CHR$(27)"E";"This program acts as a mini-ledger which will help you to post checkbook ":PRINT "or other information into an 'accountant's worksheet' type of format.":PRINT:PRINT "For complete instructions, see the accompanying documentation."
50 PRINT L$
60 PRINT "IF NOT ALREADY DONE, PLEASE PRESS THE 'CAPS LOCK' KEY ON YOUR KEYBOARD.":PRINT "ALL YOUR RESPONSES MUST BE CAPITAL LETTERS.":PRINT L$
70 PRINT "Do you want the output on paper (Y/N)?";:X$=INPUT$(1):PRINT X$
80 IF X$<>"Y" AND X$<>"N" THEN 70
90 PRINT:INPUT "Who is this work being done for";CN$
100 PRINT:INPUT "What time period is it for";DATE$
110 PRINT CHR$(27)"E"
120 PRINT:PRINT TAB(20)"*** CATEGORIES ***":PRINT
130 DIM A$(500),A(500)
140 I=I+1
150 IF I MOD 15=1 THEN GOSUB 680
160 INPUT "Category: ";A$(I)
170 IF A$(I)="-1" THEN I=I-1:PRINT "Entry was:  ";A$(I);".  Change To ";:GOTO 160
180 IF A$(I)="0" THEN 200
190 GOTO 140
200 PRINT L$:PRINT "Now input the corresponding check AMOUNTS.  The prompts will help you.":PRINT
210 PRINT TAB(20)"*** AMOUNTS ***":PRINT
220 I=0
230 I=I+1
240 IF I MOD 15=1 THEN GOSUB 690
250 IF A$(I)="0" THEN PRINT:PRINT CHR$(7);"On next entry, enter '0' unless you want to back up to a previous entry.":PRINT
260 PRINT A$(I),
270 INPUT "Amount: ";A(I)
280 IF A(I)=-1 THEN I=I-1:PRINT :PRINT "Backing up one entry.":PRINT:GOTO 260
290 IF A$(I)="0" AND A(I)=0 THEN 310
300 GOTO 230
310 PRINT L$
320 PRINT "Expenses of ";CN$;" for the period ";DATE$
330 IF X$="Y" THEN LPRINT "Expenses of ";CN$;" for the period ";DATE$
340 PRINT "Recap of your input data:":PRINT
350 IF X$="Y" THEN LPRINT L$:LPRINT "Recap of your input data:":LPRINT
360 I=0
370 I=I+1
380 IF A$(I)="0" THEN 430
390 P=P+1 : IF X$<>"Y" AND P MOD 20=0 THEN PRINT "Press Any Key To Continue":Z$=INPUT$(1)
400 PRINT A$(I),:PRINT USING F$;A(I)
410 IF X$="Y" THEN LPRINT A$(I),:LPRINT USING F$;A(I)
420 GOTO 370
430 PRINT L$:PRINT TAB(23) ">*** SUMMARY OF EXPENSES ***<":PRINT
440 IF X$="Y" THEN LPRINT L$:LPRINT TAB(23) ">*** SUMMARY OF EXPENSES ***<":LPRINT
450 FOR K=1 TO I
460 IF A$(K)="0" THEN 500
470 FOR J=K+1 TO I
480 IF A$(J)=A$(K) THEN A(K)=A(K)+A(J) : A(J)=0 : A$(J)="0"
490 NEXT J
500 NEXT K
510 PRINT TAB(20);"Category";TAB(40);"Amount of Expense"
520 PRINT TAB(20);"--------";TAB(40);"-----------------":PRINT
530 IF X$="Y" THEN LPRINT TAB(20)"Category";TAB(40);"Amount of Expense"
540 IF X$="Y" THEN LPRINT TAB(20)"--------";TAB(40);"-----------------"
550 P=0
560 FOR J=1 TO I
570 IF A$(J)="0" THEN 620
580 P=P+1 : IF X$<>"Y" AND P MOD 20 =0 THEN PRINT "Press Any Key To Continue":Z$=INPUT$(1)
590 PRINT TAB(20);A$(J);:PRINT TAB(40);USING F$;A(J)
600 IF X$="Y" THEN LPRINT TAB(20);A$(J);:LPRINT TAB(40);USING F$;A(J)
610 TOTAL=TOTAL+A(J)
620 NEXT J
630 PRINT TAB(40)STRING$(10,"-")
640 IF X$="Y" THEN LPRINT TAB(40)STRING$(10,"-")
650 PRINT TAB(20)"TOTAL EXPENSES";:PRINT TAB(40)USING F$;TOTAL
660 IF X$="Y" THEN LPRINT TAB(20)"TOTAL EXPENSES";:LPRINT TAB(40)USING F$;TOTAL
670 END
680 PRINT, "==> To STOP category input, type '0' (that is, zero)."
690 PRINT,, "==> To BACK UP to previous entry, enter '-1'."
700 RETURN
710 PRINT "AN ERROR WAS ENCOUNTERED.  PLEASE CONSULT YOUR BASIC-80 MANUAL":PRINT "REGARDING THE FOLLOWING ERROR MESSAGE.  THE ERROR OCCURRED AT PROGRAM LINE #";ERL
720 ON ERROR GOTO 0
730 REM (C)COPYRIGHT 1982 STEVEN WHITNEY.  

 

 

Valid HTML 4.01 Transitional Valid CSS
View content labeling at ICRA.
Copyright ©2007 Steven Whitney. Last modified 09/25/2007.