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

Page 107

Advertising
background image

Programming DH and DH+

Message Procedures

Chapter 6

6-16

The IF command makes logical decisions in the message procedure. The
first parameter of the IF command is an expression (see “Using
Expressions,” page 6-7). You must enclose the entire expression in
parentheses. Use multiple operators for complex or nested expressions.

The second element in the IF command is an embedded command. If the
value of the expression is true (1), the embedded command executes. If
the value of the expression is false (0), the embedded command does not
execute. The embedded command can be any available command except
another IF or an ON_ERROR command.

Figure 6.3 shows the combination of a label, a GOTO command, and an IF
command to construct a simple loop that assigns the integers 0 through 7 to
successive words in binary file 50.

Figure 6.3

Example of Looping

(other commands)

NUM = 0
LOOP:
$B50:(NUM) = NUM
NUM = (NUM + 1)
IF (NUM .LE. 7) GOTO LOOP
(other commands)

The ON_ERROR command specifies what action should be taken if an
error occurs during execution of the message procedure. The ON_ERROR
command does not execute sequentially in the procedure; it executes only
when an error occurs.

The ON_ERROR command contains an embedded command and applies
to all other commands between itself and the next ON_ERROR command.
For example:

command line 1

command line 2

ON_ERROR GOTO RECOVER

command line 3

command line 4

ON_ERROR ERR_CODE = $B2:16

command line 5

In these command lines, the first ON_ERROR command applies to
command lines 3 and 4, while the second ON_ERROR command applies
to command line 5.

IF Command

ON_ERROR Command

Advertising