Logical operators, Logical operators -6 – Rockwell Automation 1746-BAS BASIC LANGUAGE User Manual

Page 28

Advertising
background image

Publication 1746-RM001A-US-P

3-6 Expressions and Operators

Logical Operators

The module contains a complete set of logical operators that are divided into two
groups: dual-operand operators and single-operand operators.

The general form of all dual-operand instructions is:

(expr) OP (expr)

, where OP is one of the following logical operators.

These operators perform BIT-WISE logical operations on numbers between 0
(0000H) and 65535 (0FFFFH) inclusive. If the argument is outside this range,
then the module generates an

ERROR: BAD ARGUMENT

message and returns to

Command mode. All decimal places are truncated, not rounded. Use the following
table for bit manipulations on 16-bit values.

.AND.

Use the logical .AND. operator to logically AND expressions together.

.OR.

Use the logical .OR. operator to logically OR expressions together.

.XOR.

Use the logical exclusive .XOR. operator to logically XOR expressions together.

Table 3.2 Bit Manipulations on 16-Bit Values

X

Y

X .AND.Y

X .OR.Y

X .XOR.Y

0

0

0

0

0

0

1

0

1

1

1

0

0

1

1

1

1

1

1

0

Example

Result

>PRINT 3.AND.2

2

Example

Result

>PRINT 1.OR.4

5

Example

Result

>PRINT 7.XOR.6

1

Advertising