--- title: "Decision Maker 1" id: 56986 type: "computer_media" slug: "decision-maker-1" url: "http://localhost/computer_media/decision-maker-1/" markdown_url: "http://localhost/computer_media/decision-maker-1.md" published_at: "2024-10-02T01:16:58+00:00" modified_at: "2026-03-30T21:20:28+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2024/10/11_DecMkr1.png" excerpt: "A coin-flip decision maker that answers YES or NO to any question — but there's a hidden gap where it stays silent." 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: "Business" slug: "business" taxonomy: "genre" url: "http://localhost/type/business/" media_contents: - id: 56732 title: "Timex Sinclair Public Domain Library Tape 1001" type: "computer_media" url: "http://localhost/computer_media/timex-sinclair-public-domain-library-tape-1001/" media_type: "Program" mediadate: "198x" images: - url: "http://localhost/wp-content/uploads/2024/10/11_DecMkr1.png" media_type_tags: "Business" --- # Decision Maker 1 This program is a simple decision-making toy that generates a random number between 0 and 100 and prints either “YES” or “NO” depending on whether the value exceeds 49. It loops continuously, waiting for a keypress between each answer before generating a new result. Notably, the range 49–49 (i.e., exactly 49) produces neither output, a small dead-zone bug. The program uses a tight INKEY$ polling loop at line 50 as a keypress-wait mechanism, a common Sinclair BASIC idiom. *** ## Program Analysis ### Program Structure The program is short and self-contained, forming a continuous display loop across just a handful of lines. Lines 20–60 constitute the main runtime loop; lines 70–90 are utility lines for saving and auto-running the program and are never reached during normal execution. | Line(s) | Purpose | | --- | --- | | `5` | REM header identifying the program as “EXECUTIVE DECISIOL 1” (note the apparent typo: “DECISIOL” for “DECISION”) | | `10` | Clears the screen before each answer | | `20` | Generates a random number `X` in the range [0, 100) | | `30` | Prints “YES” if `X > 49` | | `40` | Prints “NO” if `X < 49` | | `50` | Busy-waits until any key is pressed | | `60` | Loops back to line 10 | | `70–90` | Unreachable utility block: CLEAR, SAVE with auto-run flag, RUN | ### Key BASIC Idioms - The `IF INKEY$="" THEN GOTO 50` polling loop at line 50 is a standard Sinclair BASIC technique for pausing execution until any key is pressed without using `PAUSE`. - `100*RND` at line 20 produces a floating-point value in [0, 100), which is compared directly without `INT`, making exact integer hits unlikely but possible. ### Bugs and Anomalies - **Silent dead-zone:** When `X` is exactly 49 (or in the interval [49, 49] due to floating-point equality), neither condition at lines 30 nor 40 is true, so nothing is printed. The screen is cleared but blank, leaving the user with no answer. The correct approach would be to use `X >= 49` or an `ELSE`-style construction. - **Typo in REM:** Line 5 reads “DECISIOL” instead of “DECISION”, suggesting a keying error in the original listing. - **No keypress-release wait:** After a keypress is detected at line 50, control immediately returns to line 10. If the key is still held, the loop will not re-trigger the wait — but because `CLS` and the random calculation execute quickly, this is unlikely to cause visible issues in practice. ### Notable Techniques The unreachable block at lines 70–90 is a common authoring pattern: `CLEAR` resets the variable space, `SAVE "1001%1"` saves the program (the `%1` encodes an inverse-video character serving as an auto-run flag), and `RUN` would restart execution. This block exists purely for distribution purposes and has no effect during normal use. ## Source Code ``` 5 REM *EXECUTIVE DECISIOL 1* 10 CLS 20 LET X=100*RND 30 IF X>49 THEN PRINT "YES" 40 IF X<49 THEN PRINT "NO" 50 IF INKEY$="" THEN GOTO 50 60 GOTO 10 70 CLEAR 80 SAVE "1001%1" 90 RUN ```