GET_ELEMENT - Return an element a string

Help Contents


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 )


InANY_STRINGThe 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.

Return Value

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:

0The first element.
1The second element.
2The third element.
-1The last element.
-2The 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.


ExampleReturn 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'

Standards Compliance

The function GET_ELEMENT is an extension to the IEC 61131-3 standard.

Further Information

String Functions

To learn about other String Functions.

Common Elements

To learn about other IEC 61131-3 Common Elements.


For the meaning of terms used in Fernhill SCADA.