ColdC: Function/Method Reference: pad()


STRING pad(STRING str, INTEGER length[, STRING filler])

This function pads or truncates string to the length length. If filler is specified, then it is used to pad the string, otherwise a space is used. If length is greater than the length of string, then pad adds filler characters on the right; however, you can force pad to add filler on the left by specifying length as a negative number.

Examples:

pad("foo", 6)
=> "foo   "

pad("foobar", 3)
=> "foo"

pad(tostr(29), -4, "0")
=> "0029"

pad("what", 20, "!?!")
=> "what!?!!?!!?!!?!!?!!"


Last Modified on 24 Mar 1996
Copyright © 1995, 1996, Brandon Gillespie