Remote Processing CAMBASIC User Manual

Page 115

Advertising
background image

Comm ands - 82

ON

Statement

SYNTAX:

O N expression GOS UB line [, line] . . .
O N expression GOTO line [, line] . . .

PURPOSE:

In the ON. .. GOT O statement, the value of the expression deter mines which line num ber in the list
will be used for branching. F or example, if the value is 3, the third line number in the list will be
the destination of the branch.

NOTE: You m ay not use labe ls with this statem ent.

REMARK S:

In the ON.. .GO SUB statement, each line number in the list must be the first number of a subroutine.

line must be a number and not a variable. Maximum number of line parameters is limited by the
number of character s you can put in a line. For simplicity, no m ore than 5 line parameters should be
used on any one program line.

If the value of expression is zero or greater than the number of line param eters, the stateme nt is
ignored.

RELATED:

RETURN

EXAMPLE:

200 ON R GOTO 150,300,320,390

If R= 1, the progr am goes to line 150

If R= 2, the progr am br anches to line 30 0 and continue s from there. If R= 3, the branch will be to
line 320 and so on.

ERROR:

< Can’t compile> – if line does not exist
< Data negative> – for expression
< Data > 255> – for expression

Advertising