Returns the number of characters in a string.
Informal Syntax:
LEN( In )
Formal Syntax:
LEN( In:=expression )
Parameter | Type | Description |
---|---|---|
In | ANY_STRING | The string to take the length of. |
The function is overloaded and accepts either the STRING or WSTRING type for the In parameter.
The function LEN returns a UINT value representing the number of CHAR or WCHAR elements in the string In.
The return value can be larger than the number of characters you would see on a screen. A displayed code point might be encoded as multiple CHAR or WCHAR elements. For example, the Chinese character for home/room (屋) would be encoded in a STRING using three CHAR elements: 16#E5 16#B1 16#8B. The return value for this code point would be 3.
Example | Return Value |
---|---|
LEN('') | UINT#0 |
LEN('Some Text') | UINT#9 |
LEN(STRING#'屋') | UINT#3 (see note below) |
LEN("") | UINT#0 |
LEN("Some Text") | UINT#9 |
LEN(WSTRING#"屋") | UINT#1 |
Note: The Chinese character for home/room (屋) is encoded in UTF-8 as three CHAR values: 16#E5 16#B1 16#8B. So the length of the string '屋' is 3.
IEC 61131-3 Second Edition: Table 29.1.
IEC 61131-3 Third Edition: Table 34.1.
To learn about other String Functions.
To learn about string literals and the different types of encoding used.
To learn about other IEC 61131-3 Common Elements.
For the meaning of terms used in Fernhill SCADA.