On-goto – Rockwell Automation 1771-DB BASIC MODULE User Manual

Page 178

Advertising
background image

Chapter
Statements

11

11 -26

Use the ON-GOTO statement to transfer control to the line(s) you
specified with the GOTO statement (page 11 -14) when the value of the
expression following the ON statement is encountered in the BASIC
program.

All comments that apply to GOTO apply to the ON statement. If the expr
after the ON is less than zero, an

ERROR: BAD ARGUMENT

message is

generated and the BASIC module enters Command mode. If the expr after
the ON is greater than the line number list following the GOTO statement,
an

ERROR: BAD SYNTAX

message is generated. The ON-GOTO statement

provides conditional branching options within the BASIC module
program.

Syntax

ON

expr GOTO ln num

Example

>1 REM EXAMPLE PROGRAM

>10 ON Q GOTO 100,200,300

Control is transferred to line 100 if Q is equal to 0 and then to line 200 if Q
is equal to 1. If Q is equal to 2, control is transferred to line number 300,
and so on.

ON-GOTO

Advertising