Labels
Labels are identifiers where the program execution flow can jump into using either GO TO or GO SUB. Unlike variables identifiers, their scope is always global (even if declared inside functions or subroutines). Usage of labels is discouraged.
In ZX BASIC, line numbers are treated as labels:
Since line numbers are just labels, the order sequence is irrelevant. The following listing is equivalent to the above one. Notice the out-of-order line sequence:
Declaring labels
Identifiers can be used as labels. A label identifier is declared by writing it at the beginning of a line, followed by a colon:
You can use the label with GO TO and GO SUB sentences, and with the @ operator: the previous example can be rewritten using labels instead of line numbers:
A label can also be referred before it has been declared: