three", "n is four or
more")
40 GO TO n?(100, 60, 120, 130,
10)
50 STOP
60 PRINT "n was one": STOP
100 PRINT "n was zero": STOP
120 PRINT "n was two": STOP
130 PRINT "n was three": STOP
(Do not mind the % symbols in the list of line 20; we will learn more about them in Chapter 6 – Expressions). As you enter values in the program, you will see how your input affects both the PRINT statements but also (and here's the important part) the GO TO statement on line 40 in effect creating a conditional GO TO. Moreover, instead of having to type 5 different GO TO statements like we would have in the case of IF...ELSE...END IF and ON, we only have to type one making it a great time-saver.
Obviously the ability of the select operator to take either string or numeric expressions as parameters makes it useful for many things like for example a conditional LET apart from changing the flow of our program, so other than just line numbers we just used, we can make it calculate and further enhance our decision making as we'll see in Chapter 6.
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.