
7-6
Section
Details of BASIC Commands
180
on <expression>
Syntax:
ON
<numerical expression> (
GOTO
|
GOSUB
) (<line number> | <label>) {, (<line number>
|<label>)}
Description:
Statement. Branches to one of the specified subroutines depending on the value of a numerical
expression.
Remarks:
The value of the <numerical expression> determines which subroutine will be executed.
The <line number> specifies the starting position of the subroutine.
A <label> can be used instead of a line number after a
GOSUB
statement.
If the value of the expression is 1 then first branch will be taken, if 2 then the second branch will
be taken, and so on.
The valid range of the expression is : [1…255]. If the value of the expression is out of this valid
range then an “ILLEGAL FUNCTION CALL” error (code B005) will result.
If the value of the expression is 0 or if the value of the expression exceeds the number of branches
after the
GOTO
/
GOSUB
then execution will continue with the next statement. If the
GOSUB
statement is used for branching then the subroutine should be terminated with a
RETURN
statement.
Examples:
> 10 FOR I = 1 TO 3
> 20 ON I GOSUB 100,200,300
> 30 NEXT I
> 40 END
> 100 PRINT “1”
> 110 RETURN
> 200 PRINT “2”
> 210 RETURN
> 300 PRINT “3”
> 310 RETURN
> RUN
1
2
3
See also:
Summary of Contents for C200H-ASC11
Page 1: ...C200H ASC11 ASC21 ASC31 ASCII Units Operation Manual Revised June 2000...
Page 2: ...iv...
Page 4: ...vi...