ProSoft Technology ProSoft i-View User Manual
Page 56

Data Source Files
ProSoft i-View ♦ Mobile Process Monitoring and Control Application
User Manual
Version 2.0.2
Page 56 of 106
ProSoft Technology, Inc.
September 29, 2011
The if then else clause (2) differs from the ternary conditional operator (1) in the following
ways:
(1) executes when any of expr, expr1, expr2 generate a change event. The result is
always updated and will be consistent with the values of expr, expr1 and expr2 at all
times. The execution will in turn trigger relevant change events up the expressions tree
just as any expression would do.
(2) only attends to expr change events. Any changes in expr1 or expr2 will not have an
effect until expr executes. Furthermore, if expr is false and expr2 was not specified, the
execution tree is trimmed at this stage and no further execution up the expression tree
will happen.
is useful in cases where you want to achieve a differential effect, for example to trigger
an event when a condition goes from false to true but not the oposite. This is not possible
with (1) because it will always execute both ways. Consider the following:
start
BOOL
INTERNAL label = "Start Button"; style = "Button";
write_access=0;
stop
BOOL
INTERNAL label = "Stop Button"; style = "Button";
write_access=0;
motor
BOOL
C1
label = "Motor State"; value = if start
then 1 else (if stop then 0);
The previous lines will display a Start tand a Stop button. When the Start button is
touched 1 will be written to C1. When the stop button is touched 0 will be written to C1.
Another use of the if then else clause is the implementation of a counter:
reset
BOOL
INTERNAL
label = "Reset Button"; style =
"Button"; write_access=0;
increment
BOOL
INTERNAL
label = "Tick Button"; style =
"Button"; write_access=0;
counter
DINT
HR1
label = "Counter"; value = if
reset then 0 else (if increment then counter+1);
The Reset and Tick buttons will provide in this case the interface for a counter value
written to the PLC.