MID (extract middle of a string)
The MID instruction extracts characters from the middle of a string. Use the position and number of characters provided to calculate the required parts of strings.
Languages supported: Function block diagram, ladder diagram, structured text.
This instruction applies to the Micro810, L20E, L50E, and L70E controllers.
MID

Parameter | Parameter Type | Data Type | Description |
---|---|---|---|
EN | Input | BOOL | Instruction enable.
Applies to ladder diagram programs. |
IN | Input | STRING | Any non-empty string. |
NbC | Input | DINT | Number of characters to be extracted cannot be greater than the length of the IN string. |
Pos | Input | DINT | Position of the sub-string. The sub-string first character will be the one pointed to by Pos (first valid position is 1). |
MID | Output | STRING | Middle part of the string (its length = NbC). When the number of characters to extract exceeds the length of the IN string, NbC is automatically recalculated to get the remainder of the string only. When NbC or Pos are zero or negative numbers, an empty string is returned. |
ENO | Output | BOOL | Enable output. Applies to ladder diagram programs. |
MID examples
MID function block diagram example

MID ladder diagram example

MID structured text example

(* ST Equivalence: *) sub_string := MID ('abcdefgh', 2, 4); (* sub_string is 'de' *)
Results

Provide Feedback