Make the Spectrum answer
Enter a greeting, turn it into a program, and change what it says.
We can give the Spectrum an instruction and see its answer straight away. Then we’ll keep instructions together as a program we can run again and change.
You can start here without having programmed before. We’ll explain the words and keys as we use them.
If you need the emulator or ROM setup, get the Spectrum ready first. These instructions use Emu198x v0.22.0 or later.
Find the keyboard
These examples use a 48K ZX Spectrum. Start Emu198x in its Spectrum 48K configuration, with the Sinclair copyright message on screen. The modern computer running Emu198x is our host; the Spectrum it recreates is our target. The BASIC program runs on that target.
The Spectrum keyboard has words as well as letters. A keyword is a word BASIC
recognises as an instruction or part of one. At the start of an instruction, one
key enters a whole keyword: P enters PRINT.
Use Emu198x’s Host Keyboard mode, shown in the window title. It is the default;
you can select it under Machine → Keyboard, or switch modes with
Ctrl+Shift+K on Linux (Cmd+Shift+K on macOS). Type punctuation with the usual
keys for your host keyboard layout, and use Shift for capitals. Enter submits a
line. The keyword keys still work as Spectrum keys: press P for PRINT, rather
than spelling out the word.
The Spectrum itself uses CAPS SHIFT for capitals and editing combinations, and SYMBOL SHIFT for punctuation. Host mode translates characters into those key presses for us. Original Keyboard mode exposes them directly: host Shift is CAPS SHIFT and Alt/Option is SYMBOL SHIFT. We’ll use Host mode here.
Give one instruction
Press P. PRINT appears, followed by a flashing cursor showing where the next
character will go. The cursor changes from K, for keyword entry, to L, for
ordinary letters. It is telling us how the next key will be interpreted.
Enter this instruction:
PRINT "Hello"
After pressing P for PRINT, type "Hello" using your usual quotation-mark and
capital-letter keys, then press Enter.
PRINT displays the text between the quotation marks. The marks tell BASIC where
the text starts and ends; they do not appear in the greeting. BASIC supplies the
space after its keyword, so you needn’t type an extra one there.

The report at the bottom begins 0 OK. It says the instruction finished without
a reported error. It cannot tell whether we wrote the message we intended: we check
that ourselves.
If a character is wrong before you press Enter, use Backspace to delete the character immediately before the cursor, then type the replacement. Emu198x turns Backspace into the Spectrum’s CAPS SHIFT + 0 combination.
Keep the instruction
This time, type 10 before pressing P for PRINT:
10 PRINT "Hello"
Press Enter. The Spectrum lists the numbered instruction instead of carrying it out. The number tells BASIC to store it as a program line.
At the empty input line, press R. The keyword RUN appears. Press Enter to run
the stored program. You should see Hello again. Repeat R, Enter: the program is
still there. Running it does not use it up.
The Foundations explanation of instructions explores
how precise instructions produce a result. Here, PRINT is the particular word
Sinclair BASIC uses for displaying something.
Add another line
Keep line 10 and enter line 20. Use P for PRINT again, then enter the quoted text.
The complete program is now:
10 PRINT "Hello"
20 PRINT "from the Spectrum"
Run it. The two messages appear on separate lines. Each of these PRINT
instructions finishes its output with a new line.
Now enter one more instruction, numbered 15:
10 PRINT "Hello"
15 PRINT "to you"
20 PRINT "from the Spectrum"
We entered line 15 last. Where will its message appear?
Between the other two messages. In this program, BASIC follows increasing line numbers: 10, 15, 20. The order in which we typed them does not decide the running order. Run it and compare the result with your prediction.

The numbers are labels, not a count of how many lines exist. The Foundations unit on order develops why changing the order of instructions can change a result.
Change a line
Enter 10 PRINT "Welcome", using the same keyword and quotation-mark keys.
There is already a line 10, so BASIC replaces it. Lines 15 and 20 remain:
10 PRINT "Welcome"
15 PRINT "to you"
20 PRINT "from the Spectrum"
Press K at the empty input line for LIST, then Enter. LIST shows the stored
program; RUN carries out its instructions. List it, check the new line 10, then
run it and look for Welcome.
For these short lines, entering a replacement is a useful way to edit. To bring an
existing line back into the editor, enter LIST 10, then press Home
(EDIT in Host Keyboard mode). If your host keyboard has no Home key, switch to Original Keyboard,
press Shift + 1, release both keys, then switch back to Host Keyboard. The line appears at the bottom. The arrow keys move
within it; Backspace deletes the character before the cursor. Press Enter to store it
again. Pressing Enter without a change keeps the same line.
A line number entered on its own deletes that stored line. Keep all three lines for the next lesson.
When the screen disagrees
If Enter leaves an error marker in the input line, the Spectrum has rejected its syntax: the arrangement of symbols does not form an instruction it accepts. Check the quotation marks and the keyword. The cursor or marker is a clue to where checking failed, not proof that the character at that position caused it.
If you see a listing instead of your greeting, the line was stored successfully; use R, Enter to run it. If the wrong message appears, use K, Enter to inspect what is stored. A new line number adds a line; reusing the old number replaces it.
We now have a small working cycle: enter an instruction, run the program, inspect its result, and make a deliberate change. Next we’ll give the greeting a name to use, and keep a copy outside the running Spectrum.
Sources
Steven Vickers, edited by Robin Bradbeer, ZX Spectrum BASIC Programming, second edition (Sinclair Research, 1983), introductory keyboard and editing notes, and chapter 2, “Basic programming concepts”. These describe keyword modes, numbered lines, editing and running a stored program.