Inserts a string into another string at a position in the string.
Informal Syntax:
Formal Syntax:
INSERT( In1:=expression, In1:=expression, P:=Expression )
Parameter | Type | Description |
---|---|---|
In1 | ANY_STRING | The target string. |
In2 | ANY_CHARS | The string or character to insert. |
P | ANY_INT | The insert position (1-based). |
The function is overloaded and accepts a range of types for the In1 and In2 parameters:
Position P is 1-based, where 1 represents the first character in the string, 2 represents the second character in the string, and so on.
If position P is zero or negative, parameter In2 is inserted at the start of In1. If position P is greater than the length of In1, parameter In2 is inserted at the end of In1.
The function returns the result of string or character In2 inserted into string In1 at position P.
The type of the return value is the same type as the In1 parameter.
Example | Return Value |
---|---|
INSERT('Item', '*', 0 ) | STRING#'*Item' |
INSERT('Item', '*', 1 ) | STRING#'*Item' |
INSERT('Item', '*', 3 ) | STRING#'It*em' |
INSERT('Item', '*', 5 ) | STRING#'Item*' |
INSERT('Item', '*', 6 ) | STRING#'Item*' |
IEC 61131-3 Second Edition: Table 29.6.
IEC 61131-3 Third Edition: Table 34.6.
Note: The function allows negative values for the P parameter. The IEC 61131-3 standard states this should be an error.
Note: The function allows the P parameter to be a location outside the input string. The IEC 61131-3 standard states this should be an error.
Note: The function allows different string types as parameters. The IEC 61131-3 Third Edition 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.