Since there are no string quotes, the computer knows that it has to do some calculation: the calculation in this case is to find the value of the string variable called n$, which is whatever name you happen to have typed in last time round. Of course, the INPUT statement acts like LET n$=n$, so the value of n$ is unchanged.
The next time round, for comparison, type:
n$
again, this time without rubbing out the string quotes. Now, just to confuse you, the variable n$ has the value "n$".
Generally speaking the INPUT parser3 is very intelligent; with the exception of the example above, there is no way to insert an invalid or improperly formed entry during INPUT. For example moving the cursor back to the beginning of the line, using ⇦ and deleting the first set of quotes and pressing ENTER will produce the now familiar bleep sound and the program cursor will continue blinking until you correct the error by adding the first set of quotes again.
Now look back at that RUN 100 we had earlier on. That just jumps to line 100, so couldn't we have said GO TO 100 instead? In this case, it so happens that the answer is yes; but there is a difference. RUN 100 first of all clears all the variables and the screen, and after that works just like GO TO 100.
GO TO 100 doesn't clear anything. There may well be occasions where you want to run a program without clearing any variables; here GO TO would be necessary and RUN could be disastrous, so it is better not to get into the habit of automatically typing RUN to run a program.
Another difference is that you can type RUN without a line number, and it starts off at the first line in the program. GO TO must always have a line number or label.
Sometimes – by mistake – you write a program that you can't stop and won't stop itself. Type:
200 GO TO 200
RUN 200
This looks all set to go on for ever unless you pull the plug out; but there is a less drastic remedy. Press the BREAK key. The program will stop, saying L BREAK into program.
At the end of every statement, the program looks to see if these keys are pressed; and if they are, then it stops. The BREAK key can also be used when you are in the middle of using the cassette recorder or the printer, or various other bits of machinery that you can attach to the computer – just in case the computer is waiting for them to do something but they're not doing it. In these cases there is a different report, D BREAK - CONT repeats. CONTINUE, in this case (and in fact in most other cases too), repeats the statement where the program was stopped; but after the reports L BREAK into program or 9 STOP Statement, CONTINUE carries straight on with the next statement after allowing for any jumps to be made.
Run the name program again and when it asks you for input type:
n$ (after removing the quotes)
n$ is as of this moment an undefined variable and the computer will bleep as it doesn't recognise your inputted value as proper one. Use BREAK to get out of the program and then type:
3 Parser is a computer program that reads data – usually in the foirm of a string of characters – analyses it and makes sure it conforms into a rigid syntax and/or set of rules in order to become meaningful to the computer
ZX Spectrum Next User Manual, 3rd Edition (ISBN 978-1-5272-5496-1), written and illustrated by Phoebus R. Dokos. Copyright © 2020-2024 Phoebus Dokos / SpecNext Ltd. Licensed under CC BY-NC-SA 4.0. This is a transcription and can contain errors; check any doubt against the printed page.