SA0038: Read access to output variable
Detects output variables (VAR_OUTPUT) which are accessed with read permission within the POU
Justification: According to the IEC 61131-3 standard, it is prohibited to read an output within a POU. This is an indication that the output is not only used as an output but also as a temporary variable for intermediate results. This kind of dual use should be avoided.
Importance: Low
Example 48. Example
VAR_GLOBAL
g_xGlob AT %QX0.0 : BOOL ;
g_iGlob AT %QW1 : INT ;
END_VARPROGRAM PLC_PRG
VAR_OUTPUT
xVarOut1:BOOL;
xVarOut2:INT;
xVarOut3:INT;
END_VAR
VAR
iCondition : INT;
END_VARiCondition := iCondition + INT#1;
CASE iCondition OF
INT#1:
xVarOut1 := g_xGlob;
xVarOut2 := g_iGlob;
INT#2:
xVarOut3 := xVarOut2; // SA0038
ELSE
xVarOut1 := FALSE;
g_xGlob := xVarOut1; // SA0038
xVarOut2 := INT#0;
xVarOut3 := INT#-1;
END_CASEOutput in the Messages view:
SA0038: Read access to output variable 'xVarOUT2'
SA0026: SA0038: Read access to output variable 'xVarOUT1'