Configuration | Rules For a property, a local input variable is implicitly created with the name of the property. The following Set function of a property thus assigns the value of the implicit local input variable of the property to an FB variable. Function block FB_Sample: FUNCTION_BLOCK FB_Sample VAR nParameter : INT; END_VAR Set function of the property SampleProperty: nParameter := SampleProperty; In the following Set function, the implicit input variable of the property is assigned to itself. The assignment of a variable to itself does not constitute a recursion, so that this Set function does not generate an SA0160 error. Set function of the property SampleProperty:
SampleProperty := SampleProperty; // no error SA0160 However, access to a property using the THIS pointer is qualified. By using the THIS pointer, the instance and thus the property is accessed, rather than the implicit local input variable. This means that the shadowing of implicit local input variables and the property itself is lifted. In the following Set function, a new call to the property is generated, which leads to a recursion and thus to error SA0160. Set function of the property SampleProperty: THIS^.SampleProperty := SampleProperty; // => SA0160 4.2.1.7 SA0161 - SA0181 | SA0161 - SA0181 4.2.1.7.1 SA0161: Unpacked structure in packed structure | SA0161:
Unpacked structure in packed structure Sample: The structure ST_SingleDataRecord is packed but contains instances of the unpacked structures ST_4Byte and ST_9Byte. This results in a SA0161 error message. {attribute 'pack_mode' := '1'} TYPE ST_SingleDataRecord : STRUCT st9Byte : ST_9Byte; // => SA0161 st4Byte : ST_4Byte; // => SA0161 n1 : UDINT; n2 : UDINT; n3 : UDINT; n4 : UDINT; END_STRUCT END_TYPE Structure ST_9Byte: TYPE ST_9Byte : STRUCT nRotorSlots : USINT; nMaxCurrent : UINT; nVelocity : USINT; nAcceleration : UINT; TE1200 72 Version: 2.11.1 Function Determines unpacked structures that are used in packed structures.
Reason The compiler normally places an unpacked structure on an address that allows aligned access to all elements within the structure. If you create this structure in a packed structure, aligned access is no longer possible, and access to an element in the unpacked structure can lead to a misalignment exception at runtime. Importance High