This program implements a checkbook reconciliation tool that calculates a running statement balance by collecting deposit totals and outstanding check amounts. The user inputs a closing statement balance, individual deposits (terminated by 0), and individual checks (terminated by 0, stored in a 200-element array). It then displays summary totals and computes a reconciled balance using the formula (statement balance + deposits) − checks. An optional screen displays all entered check amounts in a columnar layout across up to four columns of 21 rows each, using PRINT AT for precise positioning, with FAST/SLOW mode switching during the check-listing routine for faster screen rendering.
Program Analysis
Program Structure
The program is divided into several functional phases:
- Initialization (lines 10–90): All working variables and the 200-element array
Bare set to zero or their initial values. - Data Entry (lines 200–400): The user enters the closing statement balance
A, then deposits one by one (accumulated inI, counted inE), then checks one by one into arrayB(accumulated inK, counted inC). - Summary Display (lines 490–590): Prints deposit count/total, check count/total, and the reconciled balance
(A+I)-K. - Menu / Branching (lines 600–670): Offers three options — list checks (Y), show book balance (B), or quit (N).
- Check Listing (lines 690–770): Displays checks in a columnar layout using
PRINT AT, with paging controlled byFAST/SLOWand a keypress wait. - Continuation (lines 1000–1040): After listing completes, waits for a keypress and returns to the menu.
Variable Usage
| Variable | Purpose |
|---|---|
A | Ending statement balance |
B() | Array holding up to 200 individual check amounts |
C | Count of checks entered |
D | Temporary deposit input variable |
E | Count of deposits entered |
I | Running sum of deposits |
J | Loop upper bound (initially 200, later reused as C) |
K | Running sum of checks |
L | Line counter within current screen page column |
S | Loop index for check display |
T | Total checks printed so far |
W | Current row for PRINT AT |
X | Current column offset for PRINT AT |
Z | Set to 0 at line 495 but never used subsequently |
Columnar Check Display
The check-listing routine at lines 690–730 arranges checks into four columns of 21 rows each on a single screen. The variable L tracks how many items have been printed in the current set of columns, and W/X track the current row and column offset for PRINT AT. When L reaches 21, 42, or 63, the display advances to the next column (incrementing X by 8 and resetting W to 0). When L reaches 84, a full screen of 84 checks has been printed and the display pauses.
FAST mode is engaged at line 691 before printing begins to speed up screen rendering, and SLOW is restored before each keypress pause at lines 745 and 1005.
Key BASIC Idioms
- Deposits and checks use a sentinel-value loop: input continues until the user enters
0, at which point a conditionalGOTOjumps past the loop. - The menu at lines 630–660 polls
INKEY$in a tight loop, branching on “N”, “B”, or “Y”, and repeating on empty string — a standard keypress-detection pattern. PAUSE 300followed byIF INKEY$<>""/IF INKEY$=""provides a timed keypress wait at lines 750–770 and 1010–1020.
Bugs and Anomalies
- Line 718 dead code: The condition
IF L<>21 OR L<>42 OR L<>63 OR L<>84is always true (a value cannot simultaneously equal all four), so this line unconditionally executesGOTO 730, making the preceding column-advance code at lines 728–729 unreachable via this path. Column advancement only triggers if control falls through from lines 715–716. - Variable
Z: Initialized at line 495 but never read or modified elsewhere — it is unused. - Variable
Jreuse:Jis initialized to 200 as the FOR loop bound at line 350, then overwritten withCat line 590 and again at line 692. This is harmless but potentially confusing. - Line 735
GOTO 700: AfterNEXT Sat line 730 exhausts the loop, line 735 jumps back toPRINT ATat line 700 referencingB(S)whereSis now out of range; however line 732 catches theT=Ccase before this occurs in normal use. - Book balance option (B): The menu at line 640 branches to line 2000, which does not exist in the listing — this feature appears unimplemented.
Content
Source Code
1 REM "CHECKBOOK"
10 LET A=0
15 DIM B(200)
20 LET B=0
25 LET L=0
30 LET C=0
35 LET W=0
40 LET D=0
45 LET X=0
50 LET E=0
55 LET T=0
60 LET F=0
70 LET J=200
80 LET I=0
90 LET K=0
200 PRINT "INPUT ENDING STATEMENT BALANCE"
210 INPUT A
220 PRINT "INPUT DEPOSIT THIS STATEMENT","PERIOD"
230 PRINT "IF LAST DEPOSIT, INPUT 0"
240 INPUT D
250 IF D=0 THEN GOTO 300
260 LET I=I+D
270 LET E=E+1
280 GOTO 240
300 PRINT "INPUT CHECKS OUT"
310 PRINT "IF LAST CHECK ENTERED, ENTER 0"
350 FOR J=1 TO J
360 INPUT B(J)
370 IF B(J)=0 THEN GOTO 490
380 LET K=K+B(J)
390 LET C=C+1
400 NEXT J
490 CLS
495 LET Z=0
500 PRINT "THERE WERE ";E;" DEPOSITS DURING","THIS STATEMENT TOTALING $ ";I
505 PRINT
510 PRINT "THERE WERE ";C;" CHECKS OUT"," TOTALING $ ";K
515 PRINT
520 PRINT "STATEMENT BALANCE IS $ ";(A+I)-K
525 PRINT
590 LET J=C
600 PRINT "IF YOU WANT TO SEE ENTERED","CHECKS, ENTER Y"
610 PRINT "IF YOU WISH A BOOK BALANCE,","ENTER B"
620 PRINT "IF YOU ARE THRU, ENTER N"
630 IF INKEY$="N" THEN STOP
640 IF INKEY$="B" THEN GOTO 2000
650 IF INKEY$="Y" THEN GOTO 690
660 IF INKEY$="" THEN GOTO 630
665 CLS
670 GOTO 600
690 CLS
691 FAST
692 LET J=C
695 FOR S=1 TO J
700 PRINT AT W,X;B(S)
710 LET L=L+1
711 LET T=T+1
712 LET W=W+1
713 IF T=C THEN GOTO 1000
715 IF L=21 OR L=42 OR L=63 THEN GOTO 728
716 IF L=84 THEN GOTO 720
718 IF L<>21 OR L<>42 OR L<>63 OR L<>84 THEN GOTO 730
720 LET L=0
722 LET W=0
724 LET X=0
726 GOTO 738
728 LET X=X+8
729 LET W=0
730 NEXT S
732 IF T=C THEN GOTO 1000
735 GOTO 700
738 IF T=C THEN GOTO 1000
740 PRINT AT 21,0;"HIT ANY KEY TO CONTINUE"
745 SLOW
750 PAUSE 300
760 IF INKEY$<>"" THEN GOTO 690
770 GOTO 750
\n1000 PRINT AT 21,0;"HIT ANY KEY TO CONTINUE"
\n1005 SLOW
\n1010 PAUSE 300
\n1020 IF INKEY$="" THEN GOTO 1010
\n1030 CLS
\n1040 GOTO 610
\n1050 SAVE "1016%8"
\n1060 RUN
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.
