ExST Assignment: S=
When the operand of the Set assignment switches to TRUE, then TRUE is assigned to the variable to the left of the operator. The variable is set.
<variable name> S= <operand name> ;
The variables and the operand have the data type BOOL.
PROGRAM PLC_PRG
VAR
xOperand: BOOL := FALSE;
xSetVariable: BOOL := FALSE;
END_VAR
xSetVariable S= xOperand;When the operand xOperand switches from FALSE to TRUE, then TRUE is also assigned to the variable xSetVariable. But then the variable keeps this 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.
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.