Read & Spell

Date: 198x
Type: Program
Platform(s): TS 2068

This program is a reading and spelling memory game that displays a short phrase, waits for the user to read it, then prompts them to type it from memory. A random phrase is selected from eleven DATA statements by iterating through READ a random number of times, leaving the last-read value in A$. The comparison at line 110 skips the first character of both strings (using the slice A$(2 TO) and B$(2 TO)), making the check insensitive to any leading character difference such as capitalisation. Correct answers are rewarded with a BEEP and a flashing INK 3 message, after which the program restarts with RUN.


Program Structure

The program is a self-contained loop with three phases: phrase selection (lines 10–40), display-and-test (lines 50–150), and data (lines 160–260). Line 9998 saves the program with autostart at line 1 (effectively line 10). Line 9997 is a STOP guard that would only be reached if execution fell through past the data block, which cannot happen in normal flow.

  1. Initialisation (10–20): Sets colours, pauses briefly, and rewinds the DATA pointer with RESTORE.
  2. Phrase selection (30–40): Picks a random integer 1–11, reads that many phrases from DATA, leaving the last one in A$.
  3. Display (50–60): Prints the phrase at row 10 and pauses proportionally to its length (LEN A$ × 20 frames ≈ 0.4 s per character).
  4. Input (70–80): Clears the screen and prompts the user to type the phrase into B$, displayed in INK 2.
  5. Feedback (90–150): Shows the typed answer in INVERSE, then either congratulates or loops back to show the phrase again.

Phrase Selection Technique

Rather than storing phrases in an array or using direct indexing, the program exploits the sequential nature of READ. It reads through the DATA list a random number of times; whatever string was read last becomes the chosen phrase. This is a common memory-saving idiom when string arrays would cost more bytes than a simple loop.

The random count is INT(RND*11)+1, which gives a uniform integer in the range 1–11, matching exactly the 11 DATA items. The incidental BEEP 1/J,3*J inside the selection loop produces a rising-pitch chirp sequence as a side effect of the iteration.

Notable Techniques

  • Paced display: PAUSE (LEN A$)*20 gives longer phrases proportionally more reading time, a simple but effective adaptive delay.
  • INVERSE prompt echo: Line 90 wraps B$ in spaces under INVERSE 1, giving the typed text a highlighted appearance without any manual AT positioning.
  • Proportional success beep: BEEP .3,LEN A$ makes the reward tone’s pitch vary with the phrase length — longer phrase, higher note.

The String Comparison Bug

Line 110 compares A$(2 TO ) with B$(2 TO ), intentionally or accidentally skipping the first character of each string. This means the user can type any character in place of the first letter and still be marked correct. For example, typing "xatch the dog run" would pass the check for "Watch the dog run". This is almost certainly an unintentional bug rather than a deliberate case-folding strategy, since it applies to any character, not just alphabetic ones, and no other normalisation is performed.

A secondary consequence is that if B$ is empty or a single character, B$(2 TO ) is an empty string, while A$(2 TO ) is not, so the condition correctly evaluates to false in that edge case.

Data Set

LinePhrase
160Watch the dog run
170The cat has four legs
180The egg is brown
190The sun is hot
200The fox runs quickly
210The duck swims slowly
220The camel has a hump
230The bell is ringing
240The fish is wet
250The book is open
260The bus is red

All but the first phrase follow a “The [animal/object] is/has [attribute]” pattern, suggesting the program was designed as an early-reader educational tool. The phrases are short enough to be memorised in one reading and simple enough for young learners.

Content

Appears On

Capital Area Timex Sinclair User Group’s Library Tape.

Related Products

Related Articles

Related Content

Image Gallery

Source Code

   10 INK 1: PAPER 7: BORDER 7: CLS 
   20 PAUSE 50: RESTORE 
   30 FOR J=1 TO INT (RND*11)+1
   40 BEEP 1/J,3*J: READ A$: NEXT J
   50 PRINT AT 10,0;A$
   60 PAUSE (LEN A$)*20
   70 CLS 
   80 INPUT INK 2;"Now enter the phrase you","have just read",,B$
   90 PRINT INVERSE 1;" ";B$;" "
  100 PAUSE 50
  110 IF A$(2 TO )=B$(2 TO ) THEN BEEP .3,LEN A$: PRINT '' INK 3; FLASH 1;"Well done, that was correct": PAUSE 300: RUN 
  120 PRINT ''"Sorry, that was not right"
  130 PRINT ''"Here it is again"
  140 PAUSE 200: CLS 
  150 GO TO 50
  160 DATA "Watch the dog run"
  170 DATA "The cat has four legs"
  180 DATA "The egg is brown"
  190 DATA "The sun is hot"
  200 DATA "The fox runs quickly"
  210 DATA "The duck swims slowly"
  220 DATA "The camel has a hump"
  230 DATA "The bell is ringing"
  240 DATA "The fish is wet"
  250 DATA "The book is open"
  260 DATA "The bus is red"
 9997 STOP 
 9998 SAVE "READ&SPELL" LINE 1

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

People

No people associated with this content.

Scroll to Top