Decision Maker 1

This file is part of Timex Sinclair Public Domain Library Tape 1001 . Download the collection to get this file.
Date: 198x
Type: Program
Platform(s): TS 1000
Tags: Business

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
5REM header identifying the program as “EXECUTIVE DECISIOL 1” (note the apparent typo: “DECISIOL” for “DECISION”)
10Clears the screen before each answer
20Generates a random number X in the range [0, 100)
30Prints “YES” if X > 49
40Prints “NO” if X < 49
50Busy-waits until any key is pressed
60Loops back to line 10
70–90Unreachable 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.

Content

Appears On

Assembled by Tim Ward from many sources. Contains programs 10001 – 10050.

Related Products

Related Articles

Related Content

Image Gallery

Decision Maker 1

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 

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.

People

No people associated with this content.

Scroll to Top