String functions
String functions operate on ANY_STRING (STRING, WSTRING); a few accept
ANY_CHARS (also CHAR/WCHAR) for the search/replace fragment. Character
positions are 1-based — the first character is at position 1, and FIND
returns 0 when the substring is not present.
| Function | Parameters | Returns |
|---|---|---|
LEN | IN : ANY_STRING | INT |
LEFT | IN : ANY_STRING, L : ANY_INT | ANY_STRING |
RIGHT | IN : ANY_STRING, L : ANY_INT | ANY_STRING |
MID | IN : ANY_STRING, L : ANY_INT, P : ANY_INT | ANY_STRING |
CONCAT | IN : ANY_STRING (2+ args) | ANY_STRING |
INSERT | IN1 : ANY_STRING, IN2 : ANY_STRING, P : ANY_INT | ANY_STRING |
DELETE | IN : ANY_STRING, L : ANY_INT, P : ANY_INT | ANY_STRING |
REPLACE | IN1 : ANY_STRING, IN2 : ANY_CHARS, L : ANY_INT, P : ANY_INT | ANY_STRING |
FIND | IN1 : ANY_STRING, IN2 : ANY_CHARS | ANY_INT |
LEN — length
Section titled “LEN — length”LEN(IN : ANY_STRING) : INTn := LEN('Hello'); // 5LEFT, RIGHT — leading / trailing substring
Section titled “LEFT, RIGHT — leading / trailing substring”Return the first / last L characters of IN.
LEFT(IN : ANY_STRING, L : ANY_INT) : ANY_STRINGRIGHT(IN : ANY_STRING, L : ANY_INT) : ANY_STRINGprefix := LEFT(code, 3); // first 3 characterssuffix := RIGHT(code, 2); // last 2 charactersMID — substring at a position
Section titled “MID — substring at a position”MID(IN : ANY_STRING, L : ANY_INT, P : ANY_INT) : ANY_STRINGReturns L characters from IN starting at 1-based position P.
middle := MID('ABCDEF', 3, 2); // 'CDE' starts at position 2 -> 'CDE'CONCAT — concatenation
Section titled “CONCAT — concatenation”CONCAT is variadic (two or more inputs).
CONCAT(IN : ANY_STRING, ...) : ANY_STRING // 2+ argsgreeting := CONCAT('Hello, ', name, '!');INSERT — insert a string
Section titled “INSERT — insert a string”INSERT(IN1 : ANY_STRING, IN2 : ANY_STRING, P : ANY_INT) : ANY_STRINGInserts IN2 into IN1 after 1-based position P.
result := INSERT('ABEF', 'CD', 2); // 'ABCDEF'DELETE — remove characters
Section titled “DELETE — remove characters”DELETE(IN : ANY_STRING, L : ANY_INT, P : ANY_INT) : ANY_STRINGRemoves L characters from IN starting at 1-based position P.
trimmed := DELETE('ABCDEF', 2, 3); // remove 'CD' -> 'ABEF'REPLACE — replace a span
Section titled “REPLACE — replace a span”REPLACE(IN1 : ANY_STRING, IN2 : ANY_CHARS, L : ANY_INT, P : ANY_INT) : ANY_STRINGReplaces L characters of IN1 starting at 1-based position P with IN2.
fixed := REPLACE('ABCDEF', 'XY', 2, 3); // replace 'CD' -> 'ABXYEF'FIND — locate a substring
Section titled “FIND — locate a substring”FIND(IN1 : ANY_STRING, IN2 : ANY_CHARS) : ANY_INTReturns the 1-based position of the first occurrence of IN2 within IN1, or
0 if it is not found.
pos := FIND(line, 'ERROR'); // 0 when not presentIF pos > 0 THEN // handle the error markerEND_IF