|
A function that can be used in Formulas.
padRight$ (string$, minimumNewWidth [, pad$])
pad$) to the right of string$ until the result is at least as long as minimumNewWidth: assert padRight$ ("hello", 12, ".") = "hello......."
assert padRight$ ("hello", 5, ".") = "hello"
If pad$ is not given, the padding will be done with spaces:
assert padRight$ ("hello", 12) = "hello "
No truncation takes place, so the resulting string may be longer than minimumNewWidth:
assert padRight$ ("hello", 3) = "hello"
assert padRight$ ("hello", -100) = "hello"
If pad$ contains more than one character, the right edge of pad$ is right-aligned to the resulting string, so that the result will look good if padding is used for visualizing columns:
assert padRight$ ("hello", 12, ".-;)") = "hello-;).-;)"
assert padRight$ ("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$ = padRight$ ("hello", 12, "")
© Paul Boersma 2024