Detects the use of a global variable in function blocks without them being declared there as “VAR_EXTERNAL”
Justification: According to the IEC 61131-3 standard, access to global variables is permitted only by an explicit import by
means of a VAR_EXTERNAL
declaration.
Importance: Low
PLCopen rule: CP18
Example
VAR_GLOBAL iGlob1:INT; END_VAR PROGRAM PLC_PRG VAR ivar:INT; END_VAR ivar:=iGlob1; // SA0121 --> SA0121: EXTERNAL declaration required for variable ''iGlob1'
Example: Avoid error
VAR_GLOBAL iGlob1:INT; END_VAR PROGRAM PLC_PRG VAR ivar:INT; END_VAR VAR_EXTERNAL iGlob1:INT; END_VAR ivar:=iGlob1; // OK