Rockwell Automation 1775-S5_SR5,D17756.5.5 User Manual PLC-3 FAMILY I/0 User Manual

Page 99

Advertising
background image

Programming DH and DH+

Message Procedures

Chapter 6

6-8

For example, the following command stores the value 12 in word 45 of
binary file 67.

$B67:45 = 6+3*2

This occurs because the scanner multiplies before it adds.

If an expression contains several operators within the same order of
execution, the scanner executes those operators in the left-to-right order in
which they appear within the expression.

You can enter extra sets of parentheses to change the order of execution.
In such cases, the scanner evaluates the expression within the inner-most
set of parentheses first.

For example, the following command stores the value 2 in word 45 of
binary file 67 (% is the operator for division):

$B67:45 = 36%((6+3)*2)

You can use expressions anywhere for direct numeric values in a message
procedure, including within an address field.

For example, in the following statement, the expression (WORD+3)
specifies the address of a word within binary file 67:

$B67:(WORD+3) = 5

The parentheses are necessary to indicate that +3 is part of the word
address in this case.

Interpreting Expressions

Within an expression, the scanner always interprets direct numeric values
as decimal (base 10) numbers unless you indicate that they are octal (base
8). Specify an octal value by starting the number with a leading zero.

For example, the scanner interprets 17 in an expression as decimal 17, but
it interprets 017 as an octal 17 (or decimal 15).

Advertising