Configuration | Rules FUNCTION_BLOCK FB_Sample VAR_INPUT nIn : INT; END_VAR VAR_OUTPUT nOut : INT; END_VAR VAR pFB : POINTER TO FB_Sample; pINT : POINTER TO INT; END_VAR IF pFB 0 THEN pINT := ADR(pFB^.nOut); // => SA0170 END_IF nOut := nIn; pINT := ADR(THIS^.nOut); // no error due to internal usage pINT := ADR(nOut); // no error due to internal usage Accesses within another function block, in this case in the MAIN program: PROGRAM MAIN VAR fbSample : FB_Sample; pExternal : POINTER TO INT; refExternal : REFERENCE TO INT; END_VAR pExternal := ADR(fbSample.nOut); // => SA0170 refExternal REF= fbSample.nOut; // => SA0170 4.2.1.7.10 SA0171:
Enumerations should have the 'strict' attribute | SA0171: Enumerations should have the 'strict' attribute For more information see: PLC > Reference programming > Pragmas > Attribute pragmas > Attribute 'strict' Sample: {attribute 'qualified_only'} {attribute 'strict'} TYPE E_TrafficLight : ( eRed := 0, eYellow, eGreen ); END_TYPE {attribute 'qualified_only'} TYPE E_MachineStates : // => SA0171 ( eStopped := 0, eRunning, eError ); END_TYPE 4.2.1.7.11 SA0172: Possible attempt to access outside the array limits | SA0172: Possible attempt to access outside the array limits Sample: TE1200 77 Version:
2.11.1 Function Detects declarations of enumerations which are not provided with the {attribute 'strict'} attribute. Reason The {attribute 'strict'} attribute causes compiler errors to be issued if the code violates strict programming rules for enumerations. By default, when a new enumeration is created, the declaration is automatically assigned the 'strict' attribute. Importance High Function Determines possible accesses to an array index outside the array limits. Reason The range of the array index is often exceeded in FOR loops in which the index variable is used to access an array index. Importance High