meta data for this page
This is an old revision of the document!
STRING type variables
STRING also has two subtypes, just like CHAR. The old, “old-school” STRING, which describes the text with ASCII characters, and WSTRING, which uses WCHAR characters with two bytes per character. Both types are suitable for storing text, which can be extremely useful for communication, especially in HMI connections.
For both types, the first two positions show the maximum length of the given STRING and the current length it has been filled with. One position equals one byte for STRING, and one word for WSTRING.
In the example above, taken from the PLC status, I entered the phrase “lama!” into an 8-byte STRING variable. The first two bytes contain the maximum length of the STRING (8) and the current length (5), followed by the phrase as our message.
If I change the display format to hexadecimal for the characters, I see the ASCII code for each letter.
That is, the letter “l” is ASCII 16#6C, and “a” is ASCII 16#61, …
For WSTRING, this assignment appears like this:
The “$00l” content type is due to the nature of UNICODE, as “simple” characters do not fill the entire UCS-2 space. It is clear that while we counted the positions per byte above, in this case each position occupies a word. The first two words here also contain the maximum length of the STRING (8) and the current length (5).
The same definition is given in hexadecimal form as follows:



