Codesys Split String Apr 2026

xDone := TRUE; END_IF

Fast, handles arrays automatically. Cons: Requires specific libraries that might not be on every legacy PLC. Method 2: Manual Loop Parsing (Universal) If you cannot guarantee the SysStr library exists on your target (e.g., older Wago, Beckhoff CX, or embedded CODESYS), you need the manual method. codesys split string

WHILE iCurrentPart <= 10 AND iStart <= LEN(sWork) DO iPos := FIND(sWork, sDelimiter, iStart); IF iPos > 0 THEN // Extract substring aParts[iCurrentPart] := MID(sWork, iPos - iStart, iStart); iStart := iPos + iDelimLen; iCurrentPart := iCurrentPart + 1; ELSE // Last part aParts[iCurrentPart] := MID(sWork, LEN(sWork) - iStart + 1, iStart); iPartCount := iCurrentPart; EXIT; END_IF END_WHILE xDone := TRUE; END_IF Fast, handles arrays automatically

// Reset trigger IF NOT xExecute THEN xDone := FALSE; xError := FALSE; END_IF WHILE iCurrentPart &lt;= 10 AND iStart &lt;= LEN(sWork)