Rockwell Automation 57C610 Enhanced Basic Language, AutoMax User Manual

Page 48

Advertising
background image

6Ć8

In the following example:
30 GOTO 110
BASIC branches control to line 110. BASIC interprets the statement

exactly as it is written: go to line 110. There are no rules or

conditions governing the transfer.
In the sample program below, control passes in the following

sequence:
D BASIC starts at line 10 and assigns the value 2 to the variable

A%.

D Line 20 sends BASIC to line 40.
D BASIC assigns the value A% + B% to variable C%
D BASIC ends the program at line 50.
D Line 30 is never executed.
D 10 LET A% = 2

20 GOTO 40
30 LET A% = B% + 13
40 LET C% = A% + B%
50 END

The GOTO statement must be either the only statement on the line

or the last statement in a multiĆstatement line. If you place a GOTO

in the middle of a multiĆstatement line, BASIC will not execute the

rest of the statements on the line:

25 LET A% = B% + 178\ GO TO 50\ PRINT A%

In the above statement, BASIC does not execute the PRINT

statement on line 25 because the GOTO statement shifts control to

line 50.
If a ! remark statement is specified in the line number to which

control is transferred, BASIC will branch to that statement even

though it does no direct processing:

10 LET A% = 2
20 GO TO 40
30 A% = B% + 13
40 ! THIS IS ANY COMMENT
50 LET C% = A% + B%
60 END

At line 20, BASIC transfers control to line 40. No processing is

required for line 40, although some time is required to read the line.

BASIC then executes the next sequential statement, line 50.

Advertising
This manual is related to the following products: