Rockwell Automation 57C610 Enhanced Basic Language, AutoMax User Manual
Page 52

6Ć12
6.4.4
IFĆTHENĆELSE Statement
The IFĆTHENĆELSE statement provides a transfer of control based
on the result of a relational or comparison expression. It is one of the
most frequently used statements in a BASIC application task.
The IFĆTHENĆELSE statement has the following format:
IF expression THEN
ąąstatement(s)
ELSE
ąąstatement(s)
END_IF
where:
expression = boolean variable or valid relational expression
statement =
statement or series of statements separated by
backslashes or colons, or a line number to
which to transfer control. If a line number is
used, it must be defined by a GOTO statement.
If the expression following IF is evaluated as
true, all statements are executed. If a line
number is used instead of a statement, it can be
larger or smaller than the line number of the
IFĆTHENĆELSE statement.
The IFĆTHENĆELSE statement does not allow the line continuator
symbol (&). Any number of IFĆTHENĆELSE statements can be
nested if they are balanced properly. If there is no alternative to
follow the statement following THEN, do not use the ELSE keyword.
The following are valid IFĆTHENĆELSE statements:
50 IF MOTOR_SPEED% = 50 THEN
PRINT JOG_SPEED%
ELSE
PRINT MOTOR_SPEED%
END_IF
300 IF MOTOR_SPEED% > JOG_SPEED% THEN
GOTO 700
ELSE
GOTO 600
END_IF
400 IF (A > 3) THEN
A = A -12
ELSE
IF (B > C) THEN
ăă ĂC = D - 33.2
ELSE
ăă ĂC = D + 12.998
END_IF
B = B * A
END_IF
The following are invalid IFĆTHENĆELSE statements:
130 IF SWITCH_34% THEN
GOTO 300
ELSE
GOTO 500
END_IF