[REBOL] Re: Using "repeat" in write/append/lines
From: didec:tiscali at: 4-May-2004 21:48
> I am adding lines to a text file and it is one of those things that I want to print
out as many asterisks as is listed in a variable to make a simple graph. So here is
the effect I am after:
> 2pm : ****
> 3pm : **
> 4pm : *********
> The thing is how do I "print" those asterisks when I am outputting to file. I don't
know what to put in the repeat function.
> When trying out this on the console, I would try a command like:
> write/append/lines %output.txt repeat i 10 ["*"]
I think you can't use repeat like this as it doesn't return the value you want.
But insert/dup should be your friend here :
write/append/lines %output.txt insert/dup copy "" "*" nb ; with "nb" the number of
If you want to produce the graphic above, consider generating the line before adding
it to the file :
line: copy "2pm : "
insert/dup line "*" nb
write/append/line %output.txt line