String Functions
String functions work on text: building entity names and comparing text attributes. Most run in action logic; FIND and LEN also work in route, arrival, and gate conditions.
| Function | What it returns |
|---|---|
CONCAT(a, b) | The two pieces of text joined together. |
LEFT(s, n) / RIGHT(s, n) | The first / last n characters. |
MID(s, start, n) | n characters starting at position start, counting from 1. |
LEN(s) | The number of characters. |
FIND(s, part) | The position of part in s, or 0 if it is not there. |
UPPER(s) / LOWER(s) | The text in upper / lower case. |
TRIM(s) | The text with leading and trailing spaces removed. |
REPLACE(s, old, new) | The text with every old replaced by new. |
An example of each
Section titled “An example of each”Each line below is a complete piece of action logic, with a // note saying what it does and what it works out to. Text is written in double quotes.
Building a piece of text, and taking a piece out of one:
// Join two pieces of text: order 1234 becomes Order_1234SET a_Label TO CONCAT("Order_", a_OrderId)
// First and last characters: LEFT("ORDER-1234", 5) is "ORDER"SET a_Prefix TO LEFT(a_Code, 5)
// RIGHT("ORDER-1234", 4) is "1234"SET a_Suffix TO RIGHT(a_Code, 4)
// Characters from a position, counting from 1: MID("ORDER-1234", 7, 4) is "1234"SET a_Serial TO MID(a_Code, 7, 4)Measuring and searching:
// How many characters the text holds: LEN("ORDER-1234") is 10IF LEN(a_Code) < 10 THEN DISPLAY "Code looks too short" ENDIF
// Where a word starts, or 0 if it is not there at allIF FIND(a_Status, "Error") > 0 THEN INC v_Errors ENDIFCleaning text up before you compare it:
// Case, so a comparison works however the value was typedSET a_Upper TO UPPER(a_Region)SET a_Lower TO LOWER(a_Region)
// Leading and trailing spaces removed: TRIM(" north ") is "north"SET a_Clean TO TRIM(a_Region)
// Every occurrence swapped: REPLACE("ORDER-1234", "-", "_") is "ORDER_1234"SET a_Key TO REPLACE(a_Code, "-", "_")
