--- title: "Micro-Pro" id: 57639 type: "computer_media" slug: "micro-pro" url: "http://localhost/computer_media/micro-pro/" markdown_url: "http://localhost/computer_media/micro-pro.md" published_at: "2024-10-06T01:13:00+00:00" modified_at: "2026-04-03T07:58:10+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2024/10/micro-pro.png" excerpt: "A single-key-driven scrolling text editor that buffers up to 672 characters and displays them from AT 0,0 with a live cursor marker." 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/" indiv: - name: "Gene G. Buza" slug: "gene-g-buza" taxonomy: "indiv" url: "http://localhost/indiv/gene-g-buza/" genre: - name: "Word Processor" slug: "word-processor" taxonomy: "genre" url: "http://localhost/type/word-processor/" media_contents: - id: 56727 title: "Synchro-Sette October 1982" type: "computer_media" url: "http://localhost/computer_media/synchro-sette-october-1982/" media_type: "Program" programmers: - name: "Gene G. Buza" slug: "gene-g-buza" taxonomy: "indiv" url: "http://localhost/indiv/gene-g-buza/" mediadate: "October 1982" images: - url: "http://localhost/wp-content/uploads/2024/10/micro-pro.png" media_type_tags: "Word Processor" --- # Micro-Pro This program implements a scrolling text-ticker display using a string buffer. The variable B$ accumulates characters and is printed at screen position AT 0,0, with a cursor marker (▖ followed by a space) appended to show the current insertion point. Four control keys—coded 112, 113, 114, and 115—provide editing functions: character deletion (backspace), forward scroll by one line (32 spaces), space insertion, and cursor movement. The string B$ is constrained to a maximum length of roughly 672 characters (21 screen lines × 32 columns), enforcing a soft upper bound on the text buffer. The program relies on raw INKEY$ polling in a tight loop (lines 100–120) rather than INPUT, giving it immediate single-keypress response. *** ## Program Analysis ### Program Structure The program is divided into three functional regions: 1. **Initialisation (lines 10–20):** Clears the buffer `B$` and prints the initial cursor graphic. 2. **Input loop (lines 100–120):** Polls `INKEY$` continuously until a key is pressed, then dispatches to the command handler. 3. **Command handler (lines 1000–1530):** A chain of `IF` tests on `CODE A$` routes execution to one of four editing sub-routines, followed by a display refresh and a return to the input loop. ### Key Codes and Their Actions | Code | Key | Action | Handler | | --- | --- | --- | --- | | 114 | r | Backspace / delete last character | 1200 | | 115 | s | Insert a single space | 1300 | | 113 | q | Scroll forward one line (append 32 spaces) | 1400 | | 112 | p | Scroll back one line (trim 33 chars from end) | 1500 | ### Buffer Management All text is held in the string `B$`. Normal printable characters are appended at line 1100 after the dispatch chain finds no matching control code. The buffer’s effective maximum length is enforced by the guard at line 1030: if `LEN B$>672` when the scroll-forward key (q) is pressed, the operation is silently skipped by jumping directly to the display refresh at 1110. Similarly, line 1050 prevents the scroll-back operation when `LEN B$<32`, avoiding an attempt to slice a string shorter than 33 characters. ### Cursor Display The cursor is represented by the block graphic `▖` (ZX Spectrum char 130, zmakebas escape `\.`) followed by a space. It is appended to `B$` at print time (line 1110: `PRINT AT 0,0;B$;"▖ "`) but never stored in `B$` itself, so the buffer always contains only the actual content. ### Backspace Routine (lines 1200–1230) The delete handler at line 1200 replaces the last character of `B$` with a space (`B$( TO LEN B$-1)+" "`), prints this padded version to erase the on-screen character, then removes the trailing space before falling through to the normal display refresh. This two-step approach avoids leaving a ghost character on screen when the cursor graphic shifts left. A guard at line 1000 prevents deletion when `LEN B$=0`, jumping straight to the refresh instead. ### Scroll-Back Routine (lines 1500–1530) The scroll-back (p) handler appends a space, prints the buffer with an extra trailing space to clear any residual cursor graphic, then trims **33 characters** from the end with `B$( TO LEN B$-33)`. The asymmetry with scroll-forward (which appends 32 spaces) is intentional: the extra character accounts for the temporary space appended at line 1500 before slicing. ### Notable Techniques and Idioms - Tight `INKEY$` polling (lines 100–110) rather than `INPUT` gives immediate single-keystroke response with no Enter key required. - The dispatch chain at lines 1000–1060 uses paired guards (check boundary, then check key code) so boundary violations fall through to the no-op path at 1110 without needing explicit `ELSE` branches. - `PRINT AT 0,0;` redraws from the top-left on every keypress, effectively using the screen as a 32-column-wide viewport into the string buffer. - The cursor graphic is appended purely at print time, keeping `B$` clean and simplifying all length arithmetic. ## Source Code ``` 10 LET B$="" 20 PRINT AT 0,0;" ." 100 LET A$=INKEY$ 110 IF A$="" THEN GOTO 100 120 GOTO 1000 1000 IF CODE A$=114 AND LEN B$=0 THEN GOTO 1110 1010 IF CODE A$=114 THEN GOTO 1200 1020 IF CODE A$=115 THEN GOTO 1300 1030 IF CODE A$=113 AND LEN B$>672 THEN GOTO 1110 1040 IF CODE A$=113 THEN GOTO 1400 1050 IF CODE A$=112 AND LEN B$<32 THEN GOTO 1110 1060 IF CODE A$=112 THEN GOTO 1500 1100 LET B$=B$+A$ 1110 PRINT AT 0,0;B$;" . " 1120 GOTO 100 1200 LET B$=B$( TO LEN B$-1)+" " 1210 PRINT AT 0,0;B$ 1220 LET B$=B$( TO LEN B$-1) 1230 GOTO 1110 1300 LET B$=B$+" " 1310 GOTO 1110 1400 LET B$=B$+" " 1410 GOTO 1110 1500 LET B$=B$+" " 1510 PRINT AT 0,0;B$+" " 1520 LET B$=B$( TO LEN B$-33) 1530 GOTO 1110 ```