The size of user strings has to be correct. struct
s with the attribute [String]
have to fulfill:
- if the second parameter in the String attribute is true (e.g.
[String(<value>, true]
) the string is a wide string, therefore:- the
Size
parameter of theStructLayout
attribute has to be 6 greater than the first parameter (size) of the[String]
attribute multiplicated by 2. ([StructLayout(LayoutKind.Explicit, Size = <2*value+6>)]
) - the
m_cap
of the string'sIecWString
field (set inInit()
) has to be equal to the first parameter (size) of the[String]
attribute.
- the
- else
- the
Size
parameter of theStructLayout
attribute has to be 6 greater than the first parameter (size) of the[String]
attribute. ([StructLayout(LayoutKind.Explicit, Size = <value+6>)]
) - the
maximumLength
of the string'sIecStringEx
field (set inInit()
) has to be equal to the first parameter (size) of the[String]
attribute.
- the
Also see the [String]
pattern Iec026 asks for.
You can also view an explanation and example of a string implementation on Gitub
You can also use the provided automatic Code Fix to adjust the sizes to the definition in the [String]
attribute. ( Press Alt + Enter on the Error line to find the Code Fix in the context menu)
Assign the size
defined in the [String]
attribute to the IecStringEx
/IecWString
field. Set it (multiplicated with 2 for wide strings and) increased by 6 as the [StructLayout]
attribute's Size
parameter.