Rockwell Automation 57C610 Enhanced Basic Language, AutoMax User Manual

Page 49

Advertising
background image

6Ć9

GOTO statements can use integer expressions instead of a constant

as the transfer line number; however, the expression must have an

integer as its final data type. For example, in your task, you are

reading data from DATA statements and, depending on the value of

variable OPTION%, you want to execute a specific routine. Assume

the values of OPTION% are 0 thru 10. In this example, the routines

or option handlers are located at line numbers 1000, 1100, 1200,

etc. (they are 100 apart for the starting line number). This GOTO

statement multiplies the value of OPTION % by 100 to get the

hundreds" value of the routine (100, 200, 300, etc.). This

hundreds" value is then added to the base value of all the option

handlers, which is 1000:

10 BASE_VALUE% = 1000
15 INPUT OPTION%
20 GOTO (BASE_VALUE% + (OPTION% * 100))

ąąă.

ąąă.

ąąă.
1000 !ĆĆĆroutine for handling option #0
1010...
1020...

1100!ĆĆĆroutine for handling option #1
1110...
1120...

1200!ĆĆĆroutine for handling option #2
1210...
1220...

If the value resulting from the integer expression does not match any

line number in the task, the execution of the task will fall through to

the next statement and an error will be logged in the task error log.
The above operation can be performed more efficiently using the

ON GOTO" statement.

6.4.2

ON GOTO Statement

The ON GOTO statement is also a means of transferring control

within a program to another line, depending on the result of an

integer expression.
The ON GOTO statement has the following format:

ON integer_expression GOTO line_number_1,..., line_number_N

or

ON integer_expression GO TO line_number_1,...,

line_number_N

where:

integer_expression =

any arithmetic expression that

results in an integer value

Advertising
This manual is related to the following products: