Skip to main content

ExST Assignment: R=

When the operand of the Reset assignment switches to TRUE, then FALSE is assigned to the variable to the left of the operator. The variable is reset.

<variable name> R= <operand name> ;

The variables and the operand have the data type BOOL.

Example 66. Example
VAR
        xOperand: BOOL := FALSE;
        xResetVariable: BOOL := TRUE;
END_VAR

xResetVariable R= xOperand;

When the operand xOperand switches from FALSE to TRUE, then FALSE is also assigned to the variable xResetVariable. But then the variable keeps its state, even if the operand continues to change its state.



Multiple assignments

Important

In the case of multiple assignments within a code line, the individual assignments are not processed from right to left, but all assignments refer to the operands at the end of the code line.

Example 67. Example
FUNCTION funCompute : BOOL
VAR_INPUT
        xIn : BOOL;
END_VAR
IF xIn = TRUE THEN
        funCompute := TRUE;
        RETURN;
END_IF

PROGRAM PLC_PRG
VAR
        xSetVariable: BOOL;
        xResetVariable: BOOL := TRUE;
        xVar: BOOL;
END_VAR
xSetVariable S= xResetVariable R= funCompute(xIn := xVar);

xResetVariable gets the R= assignment of the return value of funCompute. xSetVariable gets the S= assignment of ht return value of funCompute, but not from xResetVariable.