SA0166: Maximum number of input/output/VAR_IN_OUT variables
Function | The check determines whether a defined number of input variables (VAR_INPUT), output variables (VAR_OUTPUT) or VAR_IN_OUT variables is exceeded in a function block. You can configure the parameters that are taken into account in the check by double-clicking on the row for rule 166 in the rule configuration (PLC Project Properties > category "Static Analysis" > "Rules" tab > Rule 166). You can make the following settings in the dialog that appears:
|
Reason | This is about checking individual programming guidelines. Many programming guidelines stipulate a maximum number of parameters for function blocks. Too many parameters make the code unreadable and the function blocks difficult to test. |
Importance | Medium |
PLCopen rule | CP23 |
![]() | Corresponding metrics available The following metrics are available for calculating the input and output variables as part of the metrics table: |
Sample:
Rule 166 is configured with the following parameters:
- Maximum number of inputs: 0
- Maximum number of outputs: 10
- Maximum number of inputs/outputs: 1
The following function block therefore reports two SA0166 errors, since too many inputs (> 0) and too many inputs/outputs (> 1) are declared.
Function block FB_Sample:
FUNCTION_BLOCK FB_Sample // => SA0166
VAR_INPUT
bIn : BOOL;
END_VAR
VAR_OUTPUT
bOut : BOOL;
END_VAR
VAR_IN_OUT
bInOut1 : BOOL;
bInOut2 : BOOL;
END_VAR