[REBOL] [Nifty Function of the Day] Pad
From: AJMartin::orcon::net::nz at: 15-Aug-2003 21:53
With acknowledgements to Bohdan "Bo" Lechnowsky:
Pad: function [
"Pads a value with leading zeroes or a specified fill character."
Value [string! number!] Length [integer!]
/Fill Character [char!] "Optional Fill Character".
] [Field] [
if not string? Value [
Value: form Value
]
if none? Character [
Character: #"0"
]
insert/dup Field: copy "" Character Length
change/part Field head reverse Value length? Value
head reverse Field
]
Andrew J Martin
ICQ: 26227169
http://www.rebol.it/Valley/
http://valley.orcon.net.nz/
http://Valley.150m.com/