15 a,b=10,15
20 a,b+=b,a

It's obvious from the example above that after skipping both the LET keyword and the long form of assignment, our program suddenly became more readable and much easier to write!

Labels

Apart from the line numbers (which we will see how to refer – and jump to – in the following sections) sometimes we need a way to identify and/or jump to a selected NextBASIC statement, maybe even within a multi-statement line. For this reason, NextBASIC provides us with a facility called labels. Labels are identified by the at (@) symbol prefix and a name following the naming guidelines for a procedure (See Chapter 4) and they are defined within a program starting with either the line number or the colon statement separator ( : ) if they're not defined at the start of a line. Their definition can appear anywhere within a program:

20 @onelabel: PRINT a+b
30 PRINT a+b: @anotherlabel

Labels can be used in lieu of line numbers with the following keywords: GO TO, BANK...GO TO, GOSUB, BANK...GOSUB, LIST, BANK...LIST, SAVE...LINE2 and EXIT. See relevant section for each keyword's proper syntax. BANK commands are all discussed in length in Chapter 23 – The Memory

Using LIST, RUN and cursors to edit and run programs

Going back to our program, you will need to change line 20 to:

20 PRINT a+b

You could type out the replacement in full, but it is easier to move the cursor (using the cursor keys) to just after the a, and then type:

+b (without ENTER)

The line at the bottom should now read:

20 PRINT a+b

Press ENTER and it will replace the old line 20, so that the screen looks like this:

Fig. 2 – Editing a program

10 LET a=10
15 b=15
20 PRINT a+b




NextBASIC

Fig. 2 – Editing a program

2 In the case of SAVE...LINE@label, the saved program will autostart from the beginning of the line that contains the label even if it's not the first statement in the line ²


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.