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 50polling loop at line 50 is a standard Sinclair BASIC technique for pausing execution until any key is pressed without usingPAUSE. 100*RNDat line 20 produces a floating-point value in [0, 100), which is compared directly withoutINT, making exact integer hits unlikely but possible.
Bugs and Anomalies
- Silent dead-zone: When
Xis 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 useX >= 49or anELSE-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
CLSand 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
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.
