[REBOL] Re: Quick REBOL question from a newbie
From: gerardcote::sympatico::ca at: 7-Oct-2005 19:48
Hi Glenn,
Here is a small function that I called "pad-left" that seems really natural to use for
people beginning with REBOL learning and
coming from say VB.
I used the "for" construct with the "insert" function to get a final product that is
versatile and near enough of the style you
wanted to get.
Its use can be easily deduced but my user manual is: pad-left start-number end-number
step pad-character
as in: pad-left 2 120 5 " " (white-space)
Here is my code:
pad-left: func [start end step pad-char][
end-length: length? form end
for c start end step [
n: form c ; Integer
to string cvt
insert/dup at n 1 pad-char (end-length - (length? n)) ; Real padding done here
print n
]
]
I developed the main part on a single line but found it too much ugly to keep it in this
former state...
Enjoy it!
Gerard Cote