Returns the middle n characters of a string starting at an offset.
Informal Syntax:
Formal Syntax:
MID( In:=expression, L:=expression, P:=expression )
Parameter | Type | Description |
---|---|---|
In | ANY_STRING | The input string. |
L | ANY_INT | The number of characters to return. |
P | ANY_INT | The 1-based starting offset. |
The function MID returns L characters from string In starting at position P.
The type of the return value is the same as the type of the In parameter.
The position parameter P is 1-based, where 1 represents the first character, 2 represents the second character, and so on.
If P is zero or negative, the starting position will be the first character in In. If P is greater than the length of In, an empty string will be returned.
Note: Watch carefully the ordering of the parameters. A number of other languages support a function similar to MID but the parameter order is String, Offset, Length.
Example | Return Value |
---|---|
MID('', 1, 1) | STRING#'' |
MID('Informs', 4, 3) | STRING#'form' |
MID(In:="Informed", L:=8, P:=3 ) | WSTRING#"formed" |
IEC 61131-3 Second Edition: Table 29.4.
IEC 61131-3 Third Edition: Table 34.4.
Note: The function allows negative values for the L and P parameters. The IEC 61131-3 standard states this should be an error.
Note: The function allows the L and P parameters to be a location outside the input string. The IEC 61131-3 standard states this should be an error.
To learn about other String Functions.
To learn about other IEC 61131-3 Common Elements.
For the meaning of terms used in Fernhill SCADA.