truncateRight$

A function that can be used in Formulas.

Syntax and semantics

truncateRight$ (string$, maximumNewWidth)
remove characters from the left of string$ until the result is at least as short as maximumNewWidth:
assert truncateRight$ ("hello", 3) = "hel"
assert truncateRight$ ("hello", 5) = "hello"

No padding takes place, so the resulting string may be shorter than maximumNewWidth:

assert truncateRight$ ("hello", 12) = "hello"

Note that maximumNewWidth cannot be negative:

asserterror Can never truncate a string down to -3 characters.
a$ = truncateRight$ ("hello", -3)

Links to this page


© Paul Boersma 2024