Detects the use of a global variable in only a single POU
Justification: A global variable that is used in only one location should also only be declared at this location.
Importance: Medium
PLCopen rule: CP26
Example
VAR_GLOBAL g_xVar AT %QX0.0 : BOOL ; g_iTest AT %QW1 : INT ; g_wTest AT %QW2 : WORD; END_VAR PROGRAM prog1 VAR iCondition : INT; bTemp :BOOL; END_VAR iCondition := iCondition + INT#1; IF iCondition < INT#0 THEN bTemp := g_xVar; // SA0043 - g_xVar only read in this POU ELSIF iCondition = INT#0 THEN bTemp := g_xVar; // SA0043 - g_xVar only read in this POU ELSE bTemp := g_xVar; // SA0043 - g_xVar only read in this POU g_wTest := WORD#4; // g_WTest used also in prog2 -> OK END_IF PROGRAM prog2 VAR iCondition : INT; END_VAR iCondition := iCondition + INT#1; CASE iCondition OF INT#1: g_iTest := WORD_TO_INT(g_wTest); // SA0043 - g_iTest only written in this POU INT#2: g_iTest := INT#2; // SA0043 - g_iTest only written in this POU ELSE g_iTest := INT#3; // SA0043 - g_iTest only written in this POU END_CASE --> SA0043: Global variable 'g_xVar' only used in 'prog1' --> SA0043: Global variable 'g_iTest' only used in 'prog2'