--- title: "Characters" id: 57286 type: "computer_media" slug: "characters-2" url: "http://localhost/computer_media/characters-2/" markdown_url: "http://localhost/computer_media/characters-2.md" published_at: "2024-10-04T08:07:09+00:00" modified_at: "2026-03-30T21:18:37+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2024/10/174_Char.png" excerpt: "A compact loop walks every character code from 0 to 255, printing each glyph in sequence — a handy one-glance reference to the full built-in character set." 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: "Demo" slug: "demo" taxonomy: "genre" url: "http://localhost/type/demo/" 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/174_Char.png" media_type_tags: "Demo" --- This program prints every character in the character set by iterating through all 256 character codes (0–255) using CHR$ and displaying each one consecutively on screen. The loop is built with a simple counter variable A, a PRINT with a semicolon suppressor to keep output continuous, and an IF/GOTO construct to repeat. The STOP at line 50 halts execution after all characters have been displayed. The SAVE line includes an inverse-video digit in the filename, and a RUN statement follows to allow immediate re-execution after loading. *** ## Program Analysis ### Program Structure The program is a minimal character set display utility. It uses a linear flow across just five active lines: 1. `10` — Initialises counter `A` to 0. 2. `20` — Prints the character corresponding to `A` with a trailing semicolon to suppress newlines and keep output continuous. 3. `30` — Increments `A` by 1. 4. `40` — Tests whether `A < 256`; if so, loops back to line `20`. 5. `50` — Halts execution with `STOP` once all 256 codes have been printed. Lines `60` and `70` are utility lines for saving and re-running the program and are not part of the display logic. ### Loop Mechanics The loop iterates through values 0–255 inclusive. The condition `A < 256` at line `40` means the loop body at line `20` executes for every value of `A` from 0 to 255, giving exactly 256 iterations. After `A` reaches 255, it is incremented to 256 at line `30`, the condition at line `40` fails, and execution falls through to `STOP`. ### Key BASIC Idioms - **Semicolon in PRINT:**`PRINT CHR$ A;` suppresses the automatic newline, so all 256 characters appear as a continuous stream filling the screen row by row. - **IF/GOTO loop:** A classic counted loop pattern using a plain variable and a conditional branch, equivalent to a `FOR…NEXT` but slightly more explicit about the termination condition. - **CHR$:** Converts an integer code to its corresponding display character, making this an exhaustive visual index of the entire character ROM. ### Character Coverage Codes 0–31 on Sinclair machines are control characters (space, cursor movements, etc.) and will produce non-printing or screen-effect results rather than visible glyphs. Codes 32–127 cover the standard printable ASCII-like set. Codes 128–143 are block graphics, 144–164 are UDG slots (displaying default patterns if unprogrammed), and 165 onwards includes the keyword tokens. The output therefore gives a live map of all these regions at once. ### Notable Techniques and Observations - Using `A < 256` rather than `A <> 256` or `A <= 255` is safe here because `A` is incremented by exactly 1 each iteration and cannot skip the boundary value. - A `FOR A=0 TO 255 : PRINT CHR$ A; : NEXT A` construct would have been functionally equivalent and slightly more idiomatic, but the IF/GOTO approach works correctly and was common in early listings. - No `CLS` precedes the loop, so any previous screen content remains until overwritten by the printed characters. - The `REM` at line `1` serves only as a title label (“CHARACTERS”) and has no effect on execution. ## Source Code ``` 1 REM "CHARACTERS" 10 LET A=0 20 PRINT CHR$ A; 30 LET A=A+1 40 IF A<256 THEN GOTO 20 50 STOP 60 SAVE "1017%4" 70 RUN ```