Hi Jerry,
you wrote:
>I'm fairly new to REBOL and wouldn't be surprised if there is a much better
>way to do it.

Fairly new, huh? And programming like a veteran .... nice work. One little
detail:

>substr: func [s k n /local a]
>[
>   a: ""
>   for i k k + n - 1 1 [a: join a pick s i]
>   a
>]

Do you realize that in the substr function, the second time you call substr
and evaluate the following expression

a: ""

the string "" will no longer be empty? The string will contain the result
of your last evaluation of

a: join a pick s i

That's because strings like "" in a: "" are defined gobally and retain
their value, even when they are used in functions. I'm pretty sure that is
not what you intended. To remedy the situation use either:

a: copy "" ;- guarantees that an empty string is created each time
a: make string! 0 ;- same thing.

Elan

Reply via email to