INSERT¶
Inserts a string into another string at a specified position.
Signature¶
┌─────────┐
IN1 ─┤ │
IN2 ─┤ INSERT ├─ OUT
P ─┤ │
└─────────┘
FUNCTION INSERT : ANY_STRING
VAR_INPUT
IN1 : ANY_STRING;
IN2 : ANY_STRING;
P : ANY_INT;
END_VAR
END_FUNCTION
The return type matches the input type. INSERT accepts STRING
for IN1 and IN2; P is INT. Both string inputs must share the
same type.
Inputs
Name |
Type |
Description |
|---|---|---|
|
|
The base string into which IN2 is inserted. |
|
|
The string to insert. |
|
|
Position in IN1 after which IN2 is inserted (1-based; 0 inserts at the start). |
Outputs
Name |
Type |
Description |
|---|---|---|
Return value |
|
IN1 with IN2 inserted after position P. Same type as the input strings. |
Description¶
INSERT(IN1, IN2, P) inserts IN2 into IN1 after position P.
Positions are 1-based. If P is 0, IN2 is inserted before the
first character.
Example¶
result := INSERT('Helo', 'l', 3); (* result = 'Hello' *)
result := INSERT('World', 'Hello ', 0); (* result = 'Hello World' *)
See Also¶
References¶
IEC 61131-3 §2.5.1.5.7