Chapter 14. Statement Reference
258
Syntax:
Syntax 1:
ON expression GOSUB label [,label...]
Syntax 2:
ON expression GOTO label [,label...]
Parameter:
expression
A numeric expression which returns a value from 1 to 255.
Description:
ON
...
GOSUB
or
ON
...
GOTO
block branches to a
label
in the label list according to
the value of
expression
.
• If
expression
has the value 3, for example, the target label is the third one in
the label list counting from the first.
• If
expression
has the value 0 or a value greater than the number of labels in
the label list, execution of the
ON
...
GOSUB
or
ON
...
GOTO
block causes no run-
time error and passes control to the subsequent statement.
• You can specify any number of labels so long as a statement block does not
exceed one program line (512 characters).
• You can nest
ON
...
GOSUB
statements to a maximum of 10 levels.
• When using the
GOSUB
statement together with block-structured statements
(
DEF
FN
...
END
DEF
,
FOR
...
NEXT
,
FUNCTION
...
END
FUNCTION
,
IF
...
THEN
...
ELSE
...
END
IF
,
SELECT
...
CASE
...
END
SELECT
,
SUB
...
END
SUB
and
WHILE
...
WEND
), you can nest them to a maximum of 30 levels.
• You can use
ON
...
GO TO
instead of
ON
...
GOTO
.
Flow control statement
ON...GOSUB and ON...GOTO
Branches to one of specified labels according to the value of an expression.
Summary of Contents for BHT-BASIC 100 SERIES
Page 1: ......
Page 161: ...153 Chapter 10 Sleep Function CONTENTS 10 1 Sleep Function 154...
Page 163: ...155 Chapter 11 Resume Function CONTENTS 11 1 Resume Function 156...
Page 173: ...165 Chapter 13 Backlight Function CONTENTS 13 1 Backlight Function 166...
Page 249: ...241 Example CLOSE IF kyIn Y THEN KILL Master Dat END IF Reference Statements CLFILE...