Hi all!

[EMAIL PROTECTED] wrote:
>I can't think of a way to do this:
>I wanted to write something like this:
>
>print rejoin ["my name is: " name 3 * (tab) "my hobby is: " hobby 2 *
>(tab)]
>
>where each n * (tab) is supposed to give back something like
>tab tab tab .... for n=3 etc.
>
>Of course, it doesn't work, but is there a nice way to write this?
>It's like some sort of "macro multiplier"
>How would you guys do it?

This should work, and be much faster than looping:

form-dup: func [a [any-type!] x [integer!]] [
     if x < 1 [return copy ""]
     if not string? :a [a: form :a]
     head insert/dup (make string! x * (length? a)) a x
]

You would then use it like this:

print [
     "my name is:" name form-dup "^(tab)" 3
     "my hobby is:" hobby form-dup "^(tab)" 2
]

Of course for the purpose of generating tabs, perhaps a less
general solution might be better (and faster):

tabs: func [x [integer!]] [
     head insert/dup make string! x #"^(tab)" x
]

...and similar functions for spaces, etc.

Brian Hawley

Reply via email to