SA0035: Unused input variables

Function

Determines input variables that are not assigned within the respective function block.

Reason

Unused variables make a program less easy to read and maintain. Unused variables occupy unnecessary memory space and take up unnecessary runtime during the initialization.

Note

An input is only considered to be used if it is actively referenced within the implementation (or the methods) of the function block itself.

Importance

Medium

PLCopen rule

CP24

Sample:

Function block FB_Sample:

FUNCTION_BLOCK FB_Sample
VAR_INPUT
    bIn1  : BOOL;
    bIn2  : BOOL;                // => SA0035
    bIn3  : BOOL;                // => SA0035
END_VAR
VAR_OUTPUT
    bOut1 : BOOL;
    bOut2 : BOOL;                // => SA0036
END_VAR
bOut1 := bIn1;

MAIN program:

PROGRAM MAIN
VAR
    fbSample  : FB_Sample;
END_VAR
fbSample(bIn2 := TRUE);

bIn2 is used when the function block instance is called. However, as this input variable is not used internally within the function block’s implementation, it is reported not only for bIn3, but also for bIn2 SA0035.