CODESYS MID

MID is a string function in the CODESYS Standard library that returns a specified number of characters from a string, starting from a given position. It is called as MID(STR, LEN, POS): take LEN characters from STR beginning with the character at position POS, and return the partial string. The function is declared as FUNCTION MID : STRING(255).

Source checked12/12 values · 2026-10-26

Specification

2 sources
Languageiec 61131 3
CodeMID
GroupString Functions
SyntaxMID (STR, LEN, POS)
DialectCODESYS

Parameters

NameData typeDescription
STRSTRING(255)String to be analyzed
LENINTNumber of characters, counted from the left
POSINTStart position for the partial string

Study notes

  • Declared as FUNCTION MID : STRING(255), so the returned partial string can be up to 255 characters.
  • All three arguments are inputs: STR (STRING(255)), LEN (INT) and POS (INT).
  • The source example VarSTRING1 := MID('SUSI',2,2); returns 'US'.
  • LEN is documented as the number of characters, counted from the left; POS is the start position for the partial string.
↑↓ navigate↵ openesc close