beautypg.com

Relational operators, Logical operators, Relational operators – 7 logical operators – 7 – Rockwell Automation FactoryTalk View Site Edition Users Guide User Manual

Page 553

background image

20

C

REATING

EXPRESSIONS

20–7

• •

20

Pla
ceho

lde

r

Relational operators

Relational operators compare two numeric or string values, to provide a true or false
result. If the statement is true, the expression returns a value of 1. If the statement is false,
the expression returns a value of 0.

The following table describes the relational operators, with examples. (For the numeric
examples, tag1 = 5 and tag2 = 7. For the string examples, serial_no = ST009.)

How string operands are evaluated

String operands are evaluated by case and by alphabetical order. Lower case letters are
greater than upper case letters. For example, h is greater than H. Letters later in the
alphabet are greater than those earlier in the alphabet. For example, B is greater than A.

Logical operators

Logical operators determine the validity of one or more statements. There are three logical
operators: AND, OR, and NOT. If the expression is true, the operators return a non-zero
value. If the expression is false, the operators return 0.

The following table describes the logical operators, with examples. (In the examples,
tag1 = 5 and tag2 = 7.)

Symbol

Operator

Numeric examples

String examples

EQ, ==

equal

tag1==tag2
false

serial_no==“ST011”
false

NE, <>

not equal

tag1<>tag2
true

serial_no<>“ST011”
true

LT, <

less than

tag1true

serial_no<“ST011”
true

GT, >

greater than

tag1>tag2
false

serial_no>“ST011”
false

LE, <=

less than or equal to

tag1<=tag2
true

serial_no<=“ST011”
true

GE, >=

greater than or equal to

tag1>=tag2
false

serial_no>=“ST011”
false

Symbols

Operator

Action

Example

AND, &&

and

If the statements to the right and to the left
of the operator are both true, returns a 1.

(tag1Both statements are true; returns a 1.