Download 2711E-6.14, PanelBuilder 1400e Software for Windows User Manual

Transcript
7–18
Creating Expressions
IF ( state = 0 ) THEN
result = 0
EXIT
END IF
’The motor is not running
’ The conditional expression wraps to the next line.
’ Note the use of the line continuation character ( _ ).
IF (((state AND 4) <> 0) AND NOT ((state AND 251) _
<> 0)) THEN
result = 1
EXIT
’The motor is running
END IF
IF (((state AND 4) <> 0) AND ((state AND 8) <> 0)
AND NOT ((state AND 243) <> 0)) THEN
result = 2
_
’The motor is starting, since
’run and low speed are active
EXIT
END IF
IF ((state AND 243) <> 0) THEN
result = 3
’The motor has an alarm
EXIT
END IF
The numbers used are based on converting the binary representation of the
state bits into a decimal number. For instance, when bit 2 is set, this is
equivalent to the number 4; when bit 3 is set, this is equivalent to the number
8; 243 represents all alarm bits set.
Expression Return Values
It is important to understand how an expression is evaluated in order
to correctly determine the result of the expression.
An expression will return the value of its last-executed statement.
Publication 2711E-6.14 – November 1998