--- title: "Address Label" id: 57235 type: "computer_media" slug: "address-label" url: "http://localhost/computer_media/address-label/" markdown_url: "http://localhost/computer_media/address-label.md" published_at: "2024-10-04T06:58:19+00:00" modified_at: "2026-03-30T21:19:10+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2024/10/125_AddL.png" excerpt: "A mailing label data-entry program that stores up to 100 address records in a 2D string array and sends them straight to the printer — with a name-length validator built in." 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: "Database" slug: "database" taxonomy: "genre" url: "http://localhost/type/database/" 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/125_AddL.png" media_type_tags: "Database" --- # Address Label This program collects mailing address data for up to 100 entries and prints formatted address labels to a printer using LPRINT. Each record stores four fields — name, address, city/state, and ZIP code — in a two-dimensional string array A$(100,4), with a companion array B$(4) holding the field prompt labels. A validation check at line 232–238 enforces a 30-character maximum on the name field, though the loop logic contains a bug: on a validation failure the GOTO 220 re-enters the inner loop at INPUT without re-prompting the correct field label, and J will advance past 1. After all entries are collected, the program iterates through the array and sends each field to the printer via LPRINT. *** ## Program Analysis ### Program Structure The program is divided into three logical phases: 1. **Setup (lines 110–180):** Prompts for the number of entries, dimensions the data array `A$(100,4)` and prompt array `B$(4)`, and populates `B$` with field names. 2. **Data Entry (lines 190–240):** Nested `FOR` loops (outer over records `I`, inner over fields `J`) collect input into `A$(I,J)`, with a name-length validation guard. 3. **Output (lines 310–380):** A second nested loop sends each stored field to a printer via `LPRINT`. ### Data Structures | Variable | Type | Purpose | | --- | --- | --- | | `A$(100,4)` | 2D string array | Stores up to 100 records × 4 fields each | | `B$(4)` | 1D string array | Field prompt labels (NAME, ADDRESS, etc.) | | `N` | Numeric | Number of address entries to collect | | `I`, `J` | Numeric (loop counters) | Record index and field index respectively | | `X` | Numeric | Temporary holder for name field length | ### Key BASIC Idioms - A companion label array `B$(4)` is used to drive prompt text dynamically inside the loop at line 210 (`PRINT "INPUT";B$(J)`), avoiding four separate input prompts. - `LPRINT` at line 350 sends output directly to a connected printer rather than the screen, which is the standard approach for hard-copy label generation. - Line 121 echoes `N` back to the screen immediately after input — a simple confirmation technique. ### Validation Logic and Bug Lines 232–238 implement a name-length check. After the inner `FOR J` loop body executes for `J=1` (the NAME field), `LEN(A$(I,1))` is stored in `X`. If the name exceeds 29 characters, execution jumps back to line 220 (`INPUT A$(I,J)`). However, this introduces a logic bug: the `GOTO 238` re-enters at the `INPUT` statement mid-loop without resetting `J` or re-printing the correct prompt. On a validation failure, `J` is still 1, so the re-input will overwrite `A$(I,1)` correctly — but without re-displaying the “INPUT NAME” prompt (line 210 is bypassed). If the user then passes validation and `NEXT J` at line 240… wait, line 240 is actually `NEXT I`. The inner loop’s `NEXT J` is at line 230. The validation block at lines 232–238 sits *between* `NEXT J` (line 230) and `NEXT I` (line 240), meaning it only ever checks the field collected in the *last* iteration of the J loop (field 4, ZIP CODE), not the name field. The intent was clearly to validate the name, but the check is misplaced after the inner loop closes. ### Notable Anomalies - The `DIM A$(100,4)` at line 130 allocates space for 100 records unconditionally, regardless of the value of `N` entered by the user. This wastes memory if `N` is small, and if `N` exceeds 100 the program will generate a subscript error at runtime. - There is no upper-bound check on `N` before the `DIM` statement; entering a value greater than 100 will cause an out-of-bounds error during data entry. - Lines 390–400 (`SAVE` and `RUN`) appear after `STOP` at line 380 and are only reachable by direct `GO TO` or manual execution — a common pattern for embedding a re-save/restart facility at the end of a program. - Line 250 contains a bare `PRINT` (blank line) that serves as visual spacing between the input phase and the print phase on screen. ## Source Code ``` 1 REM ADDRESS LABEL 110 PRINT "INPUT NUMBER OF NAMES" 120 INPUT N 121 PRINT N 130 DIM A$(100,4) 140 DIM B$(4) 150 LET B$(1)="NAME" 160 LET B$(2)="ADDRESS" 170 LET B$(3)="CITY AND STATE" 180 LET B$(4)="ZIP CODE" 190 FOR I=1 TO N 200 FOR J=1 TO 4 210 PRINT "INPUT";B$(J) 220 INPUT A$(I,J) 230 NEXT J 232 LET X=LEN (A$(I,1)) 234 IF X<30 THEN GOTO 240 236 PRINT "PROGRAM ONLY ACCEPTS NAMES UP TO" 237 PRINT "30 CHARACTERS LONG.TRY AGAIN" 238 GOTO 220 240 NEXT I 250 PRINT 310 FOR I=1 TO N 320 PRINT 340 FOR J=1 TO 4 350 LPRINT A$(I,J) 360 NEXT J 370 NEXT I 380 STOP 390 SAVE "1012%5" 400 RUN ```