MID¶
Returns a substring from the middle of a string.
Signature¶
┌─────────┐
IN ─┤ │
L ─┤ MID ├─ OUT
P ─┤ │
└─────────┘
FUNCTION MID : ANY_STRING
VAR_INPUT
IN : ANY_STRING;
L : ANY_INT;
P : ANY_INT;
END_VAR
END_FUNCTION
The return type matches the type of IN. MID accepts STRING
for IN; L and P are INT.
Inputs
Name |
Type |
Description |
|---|---|---|
|
|
The source string. |
|
|
Number of characters to extract. |
|
|
Starting position (1-based). |
Outputs
Name |
Type |
Description |
|---|---|---|
Return value |
|
L characters from IN starting at position P. Same type as IN. |
Description¶
MID(IN, L, P) returns L characters from IN starting at
position P. Positions are 1-based: the first character is at
position 1.
Example¶
result := MID('Hello World', 5, 1); (* result = 'Hello' *)
result := MID('Hello World', 5, 7); (* result = 'World' *)
See Also¶
References¶
IEC 61131-3 §2.5.1.5.7