SA0037: Write access to input variable

Function

Determines input variables (VAR_INPUT) that are subject to write access within the POU.

Reason

According to the IEC 61131-3 standard, an input variable may not be changed within a function block. Such access is also an error source and makes the code more difficult to maintain. It indicates that a variable is used as an input and simultaneously as an auxiliary variable. Such dual use should be avoided.

Importance

Medium

Sample:

Function block FB_Sample:

FUNCTION_BLOCK FB_Sample
VAR_INPUT
    bIn   : BOOL := TRUE;
    nIn   : INT := 100;
END_VAR
VAR_OUTPUT
    bOut  : BOOL;
END_VAR

Method FB_Sample.SampleMethod:

IF bIn THEN
    nIn  := 500;                 // => SA0037
    bOut := TRUE;
END_IF