Relational operators – Rockwell Automation 1771-DB BASIC MODULE User Manual

Page 119

Advertising
background image

Chapter
Expressions, Variables and Operators

9

9 -9

Relational expressions involve the operators =, < >, >, >=, <, and <=.
In the BASIC module, you typically use relational operations to test a
condition.

The BASIC module relational operators return a result of 65535 (0FFFFH)
if the relational expression is true, and a result of 0 if the relation
expression is false. The result returns to the argument stack. Because of
this, it is possible to display the result of a relational expression.

>PRINT 1=0

0

>PRINT 1>0

65535

>PRINT A<>A

0

>PRINT A=A

65535

You can chain relational expressions with the logical operators .AND.,
.OR., and .XOR. (page 9 -8). This makes it possible to test a complex
condition with one statement.

>10 IF (A>E).AND.(A>C).OR.(A>D)THEN...

Additionally, you can use the NOT operator (page 9 -11).

>10 IF NOT(A>E).AND.(A>C)THEN...

Important: When using logical operators to link relational expressions,
you must be sure operations are performed in the proper sequence.
When in doubt, use parentheses.

Relational Operators

Advertising