|
A function that can be used in Formulas.
padLeft$
(string$
, minimumNewWidth
[, pad$
])
pad$
) to the left of string$
until the result is at least as long as minimumNewWidth
: assert padLeft$ ("hello", 12, ".") = ".......hello"
assert padLeft$ ("hello", 5, ".") = "hello"
If pad$
is not given, the padding will be done with spaces:
assert padLeft$ ("hello", 12) = " hello"
No truncation takes place, so the resulting string may be longer than minimumNewWidth
:
assert padLeft$ ("hello", 3) = "hello"
assert padLeft$ ("hello", -100) = "hello"
If pad$
contains more than one character, the left edge of pad$
is left-aligned to the resulting string, so that the result will look good if padding is used for visualizing columns:
assert padLeft$ ("hello", 12, ".-;)") = ".-;).-;hello"
assert padLeft$ ("goodbye", 12, ".-;)") = ".-;).goodbye"
There will be an error message if padding is required but no characters are to be found in pad$
:
asserterror Empty pad string.
a$ = padLeft$ ("hello", 12, "")
© Paul Boersma 2024