Returns an element of a string. A delimiter character is used to mark the boundary between elements.
Informal Syntax:
Formal Syntax:
GET_ELEMENT( In:=expression, DLM:=expression, INDEX:=expression )
Parameter | Type | Description |
---|---|---|
In | ANY_STRING | The input string. |
DLM | ANY_CHARS | The delimiter used to mark the boundary between elements. |
INDEX | ANY_INT | The index of the element to return. If INDEX >= 0, elements are counted from the start of the In parameter. If INDEX < 0, elements are counted from the end of the In parameter. |
The function is overloaded and accepts either the STRING or WSTRING type for the In parameter.
The return value is an element of the In string delimited by the DLM parameter. The INDEX parameter determines which element is returned. For example:
INDEX | Returns |
---|---|
0 | The first element. |
1 | The second element. |
2 | The third element. |
-1 | The last element. |
-2 | The second to last element. |
If INDEX is out of range, the DLM parameter is returned.
The type of the string returned is the same as the In parameter.
Example | Return Value |
---|---|
GET_ELEMENT("No Elements", ",", 0 ) | WSTRING#"No Elements" |
GET_ELEMENT("No Elements", ",", 1 ) | WSTRING#"," |
GET_ELEMENT('Item1-Item2-Item3', '-', 0) | STRING#'Item1' |
GET_ELEMENT('Item1-Item2-Item3', '-', 2) | STRING#'Item3' |
GET_ELEMENT('Item1-Item2-Item3', '-', 3) | STRING#'-' |
GET_ELEMENT('Item1-Item2-Item3', '-', -1) | STRING#'Item3' |
GET_ELEMENT('Item1-Item2-Item3', '-', -2) | STRING#'Item2' |
The function GET_ELEMENT is an extension to the IEC 61131-3 standard.
To learn about other String Functions.
To learn about other IEC 61131-3 Common Elements.
For the meaning of terms used in Fernhill SCADA.