--- title: "Check Book" id: 57280 type: "computer_media" slug: "check-book" url: "http://localhost/computer_media/check-book/" markdown_url: "http://localhost/computer_media/check-book.md" published_at: "2024-10-04T08:01:56+00:00" modified_at: "2026-04-03T07:58:37+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2024/10/168_CkBk.png" excerpt: "A BASIC checkbook balancer lets you enter deposits and outstanding checks, then reconciles your statement balance — with a paginated check-listing view." category: - name: "Archived Media" slug: "archived-media" taxonomy: "category" url: "http://localhost/category/archived-media/" post_tag: - name: "Downloadable" slug: "downloadable" taxonomy: "post_tag" url: "http://localhost/tag/downloadable/" - name: "TS 1000" slug: "ts1000" taxonomy: "post_tag" url: "http://localhost/tag/ts1000/" model: - name: "Timex/Sinclair 1000" slug: "ts-1000" taxonomy: "model" url: "http://localhost/model/ts-1000/" genre: - name: "Finance" slug: "finance" taxonomy: "genre" url: "http://localhost/type/finance/" media_contents: - id: 56734 title: "Timex Sinclair Public Domain Library Tape 1003" type: "computer_media" url: "http://localhost/computer_media/timex-sinclair-public-domain-library-tape-1003/" media_type: "Program" mediadate: "198x" images: - url: "http://localhost/wp-content/uploads/2024/10/168_CkBk.png" media_type_tags: "Finance" --- 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: 1. **Initialization (lines 10–90):** All working variables and the 200-element array `B` are set to zero or their initial values. 2. **Data Entry (lines 200–400):** The user enters the closing statement balance `A`, then deposits one by one (accumulated in `I`, counted in `E`), then checks one by one into array `B` (accumulated in `K`, counted in `C`). 3. **Summary Display (lines 490–590):** Prints deposit count/total, check count/total, and the reconciled balance `(A+I)-K`. 4. **Menu / Branching (lines 600–670):** Offers three options — list checks (Y), show book balance (B), or quit (N). 5. **Check Listing (lines 690–770):** Displays checks in a columnar layout using `PRINT AT`, with paging controlled by `FAST`/`SLOW` and a keypress wait. 6. **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 conditional `GOTO` jumps 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 300` followed by `IF 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<>84` is always true (a value cannot simultaneously equal all four), so this line unconditionally executes `GOTO 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 `J` reuse:**`J` is initialized to 200 as the FOR loop bound at line 350, then overwritten with `C` at line 590 and again at line 692. This is harmless but potentially confusing. - **Line 735 `GOTO 700`:** After `NEXT S` at line 730 exhausts the loop, line 735 jumps back to `PRINT AT` at line 700 referencing `B(S)` where `S` is now out of range; however line 732 catches the `T=C` case 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. ## 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 1000 PRINT AT 21,0;"HIT ANY KEY TO CONTINUE" 1005 SLOW 1010 PAUSE 300 1020 IF INKEY$="" THEN GOTO 1010 1030 CLS 1040 GOTO 610 1050 SAVE "1016%8" 1060 RUN ```