Skip to content

A story worth sharing

Give the meeting a place and another event, then arrange and save the finished story.

A sleepy dragon is an unusual meeting. A sleepy dragon asking for a biscuit in a moon cave gives us something more to picture. We’ll turn our sentence builder into a small story, then make the result pleasant to read.

Continue with the final program from Ask, then use the answer. Keep that program in memory: we are adding to it. If you are joining here, enter the complete first listing below into an empty BASIC program. In Host Keyboard mode, use your usual punctuation keys; after a line number, I enters INPUT and P enters PRINT. R at an empty input line enters RUN.

Give the meeting a place

Add lines 45, 48 and 60. Keep the other lines:

10 INPUT "Your name ";n$
15 PRINT "Hello, ";n$
20 PRINT "from the Spectrum"
30 INPUT "Describing word ";a$
40 INPUT "Animal ";b$
45 INPUT "Place like moon cave ";p$
48 PRINT "In the ";p$
50 PRINT n$;" met the ";a$;" ";b$
60 PRINT "The ";b$;" asked for a biscuit"

Line 45 asks for a place and stores it in p$, another string variable. Although we type this line after the existing program, its number puts it between lines 40 and 50. Line 48 introduces the place before the meeting; line 60 adds the animal’s request afterwards.

Run it with Sam, sleepy, dragon and moon cave. At each prompt, type between the quotes already supplied and press Enter. For the place, enter moon cave, not the moon cave: the program supplies In the .

The last line uses b$ again. Reading a stored value does not use it up. The same animal can appear in both events without asking for its name twice.

Try Jo, enormous, owl and old tower. The words change, but the events remain a meeting followed by a request. We wrote that structure; the computer is filling it with answers. The surprise comes from how those choices fit together.

The final sentence may break in the middle of a word at the screen edge. Our next change will give it more room.

Make room for the story

We no longer need the greeting above the finished story. Delete lines 15 and 20: type 15 on its own and press Enter, then do the same with 20. A line number with no instruction removes that stored line.

Now replace lines 48, 50 and 60, and add lines 5, 46, 47, 55, 65, 70, 75 and 80. Here is the complete program to check against:

5 PRINT "Use short answers"
10 INPUT "Your name ";n$
30 INPUT "Describing word ";a$
40 INPUT "Animal ";b$
45 INPUT "Place like moon cave ";p$
46 CLS
47 PRINT "AN UNEXPECTED PICNIC"
48 PRINT
50 PRINT "In the ";p$
55 PRINT n$;" met the ";a$;" ";b$
60 PRINT
65 PRINT "The ";b$
70 PRINT "asked for a biscuit"
75 PRINT
80 PRINT "THE END"

For line 46, type 46, press V to enter CLS, then press Enter. CLS means clear screen. For an empty PRINT line, type its number, press P, then Enter without adding quotes or text.

There are three changes to notice:

  • Line 5 gives a short instruction while the questions are being answered.
  • Line 46 clears the display after the last answer. Printing then starts at the top again, with our title. Clearing the display leaves the program and its stored answers intact.
  • PRINT with nothing after it leaves a blank line. Lines 65 and 70 split the last sentence deliberately, keeping the animal and its request readable.

Run it with the first set of answers again.

AN UNEXPECTED PICNIC heads a story: In the moon cave, Sam met the sleepy dragon. The dragon asked for a biscuit. THE END appears below.
A title, short lines and space between events give the same words a clearer shape.

The questions appear in the Spectrum’s input area near the bottom. Our PRINT lines use the area above it. When the program finishes, the 0 OK report belongs to BASIC, not to the story.

If CLS erased the answers as well as the display, could line 50 print the place?

No. Line 50 needs the value in p$. The place appears because CLS clears what we see, while the stored answer remains available. The screen and the program’s variables have different jobs.

Make it yours

Change the quoted title in line 47 and the request in line 70. Perhaps the animal asks for directions, or offers a dance lesson. Keep the words short enough to read comfortably. Run the program after each change and see whether the title still suits what happens.

Our design works best with short answers. Try a long animal name and watch where it wraps; the line break is a display effect, not a shortened value. Empty answers still leave gaps. Use short answers is guidance for the person, not a rule enforced by the program.

Ask someone to run it without coaching them. Can they tell what sort of place to enter? Does the result make sense? If a prompt causes confusion, change that prompt and try again. A finished toy can be small; its instructions still need to work for someone who did not write it.

Keep a copy someone can run

Save the program with SAVE "story": press S at an empty input line for SAVE, then type the quoted name. At the tape prompt, press Enter and wait for 0 OK. Choose Tape → Export Recording… (Ctrl+Shift+E on Linux) and save to a new filename, such as story.tap.

The export contains all recordings in this emulator session. If you saved the greeting earlier, keep that in mind when loading: use LOAD "story" to ask for the named program rather than accepting the first one with LOAD "". The name inside the quotes is the name used by SAVE, not the host filename.

After the export confirmation, close Emu198x and restart it. Choose File → Open Tape Deck… and select your exported file. Press J for LOAD, type "story", then press Enter. Choose Tape → Play and wait for loading to finish. On Linux, launch with --tape "path/to/story.tap", enter the same LOAD "story" command, then press F9. Keep the --rom option if needed. The saving lesson explains these steps in more detail.

Run the recovered program and supply different words. Check that your new title and ending are there. The TAP is the program someone else can run; a screenshot keeps one result they can read.

Story Builder now has a complete ending. Run it again whenever you want another combination. Our next project, Lucky Number, begins with Give a useful clue. We’ll make decisions about an answer and help the player choose again.

Sources

Steven Vickers, edited by Robin Bradbeer, ZX Spectrum BASIC Programming, second edition (Sinclair Research, 1983), chapter 2 (numbered lines and string input), chapter 15, p. 103 (CLS and the input/report area), and chapter 20 (tape names, saving and loading).