How relational expressions work – Rockwell Automation 1771-DB Basic Module User Manual - Series A User Manual

Page 86

Advertising
background image

Operating Functions

Chapter 5

5–49

Relational expressions involve the operators =,

tu, u, u=, t, and t=.

These operators are typically used to “test” a condition. In the BASIC
Module relational operations are typically used to “test” a condition. In the
BASIC Module relational operators return a result of 665535 (OFFFFH) if
the relational expression is true, and a result of 0, if the relation expression
is false. The result is returned to the argument stack. Because of this, it is
possible to display the result of a relational expression.

Examples:

PRINT 1=0 PRINT 1

u0 PRINT A tu A PRINT A=A

0 65535 0 65535

You can “chain” relational expressions together using the logical operators
.AND., .OR., and .XOR.. This makes it possible to test a complex
condition with ONE statement.

Example:

u10 IF ([AuB].AND. [AuC]) .OR.[AuD] THEN

Additionally, you can use the NOT([expr]) operator.

Example:

u10 IF NOT(AuB).AND.(AuC) THEN

By “chaining” together relational expressions with logical operators, you
can test particular conditions with one statement.

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

5.5.4
How Relational Expressions
Work

Advertising