Original Author Paul Laughton, 2011
Page 82
De Re BASIC!
D_U.break
If this statement is executed within a Do-Until loop, the rest of the current pass of the loop is skipped
and the loop is terminated. The statement immediately following the Until will be executed.
Labels, GOTO, GOSUB, and RETURN: Traditional BASIC
Before computer scientists invented the looping structures and user-defined functions described above,
program flow was controlled by GOTO, GOSUB, and RETURN statements. These statements are present
in BASIC!, too, mainly for compatibility with old BASIC dialects.
A GoTo statement is a one-way jump to another place in your program, identified by a Label. The
program goes to the Label and continues execution there.
A GoSub is similar, except that the Label is the beginning of a "Subroutine". The proram goes to the
Label, and executes there until it reaches a Return statement. Then it "returns", going back to where it
came from: the line after the GoSub statement.
Extensive use of the GoTo command in your program should be generally avoided. It can make code
hard to read and harder to debug. Instead, you should use structured elements like Do...Until,
While...Repeat, etc. in conjunction with the Break and Continue statements.
It is especially serious to use GoTo commands inside an If...Else...Endif, For...Next, or other structured
block, jumping to code outside of the block. Doing this consumes system resources and may corrupt
BASIC!'s internal data structures. This practice may lead your program to a run-time error:
Stack overflow. See manual about use of GOTO.
Label
A label is a word followed by the colon ":", character. Label names follow the same conventions as
variable names, except that a label must not start with a BASIC! command keyword.
You may put a label on a line with other commands. Use two colons: one to signify that the word is a
label, and a second to separate the label from the other command(s) on the line.
Here: : IF ++a < 5 THEN GOTO here ELSE PRINT a
This program prints
5.0
and then stops.
The colon signifies that the word is a label, but it is not part of the label. Use the colon where the label is
defined. Do not use it in the GoTo or GoSub that jumps to the label.
For example:
This_is_a_Label:
@Label#3:
Loop:
% The command "GoTo Loop" jumps to this line
<statement>