Toshiba KB-80 사용자 설명서

다운로드
페이지 79
- 52 -
ON GOTO/GOSUB
Function
Branches the execution to the specified line number according to a value for
<expression>.
Format
ON <expression> GOTO <line number> [, <line number> ] ···
ON <expression> GOSUB <line number> [, <line number> ] ···
Term
<expression>:
An expression to specify <line number> which is placed after
GOTO/GOSUB.
It should be 255 or less.
(If a value is not an integer, a decimal is rounded off to the nearest
integer).
<line number>:
Line number to which the execution is branched by GOTO/GOSUB.
Explanation
The line number to which the execution is branched is determined according to the
value of <expression>.  See an example below.
ON DATA1 GOTO 10, 20, 30, 40
In the above statement, if a value for <DATA1> is 1, 2, and 3, the execution is
branched to line number 10, 20, and 30, respectively.
In the ON ~ GOSUB statement, the program which starts in each line number must
be the sub program which the RETURN statement is placed at the end of the
program.  When the value for <expression> is 0, or is larger than the number of <line
number>s, ON ~ statement is ignored, and the execution is moved to the next
statement (GOSUB statement).