15. Strings and useful text operations
function run()
let answer = lower(trim(" Open The Door "))
let words = split(answer, " ", false)
let tidy = join(words, " ")
let changed = replace(tidy, "door", "archive")
return [answer, changed, starts_with(answer, "open")]
endtrim() removes whitespace at the ends. lower() and upper() change case. contains(), starts_with() and ends_with() accept an optional case-sensitive flag; it defaults to true. replace() replaces matching text with case-sensitive matching.
split(text, delimiter, allow_empty) makes an array. Its default delimiter is a space, and empty pieces are kept unless you pass false. join(array, delimiter) goes the other way. len(text),
length(text) and string_length(text) report length.
function run()
let line = format("{name} found {count} gears.", {"name": "Ada", "count": 3})
let numbered = format("{0}: {1}", ["Score", 25])
return [line, numbered]
endformat() replaces braces with dictionary keys, zero-based array positions, or {value} for a single value. It is not a printf-style format engine. GUI wildcards such as $$score belong to the GUI text substitution system; ordinary PCA string values do not automatically expand them.
