[plt-scheme] insert in a text%
At Fri, 14 Jan 2005 22:59:11 +0100 (CET), pietri bob wrote:
> how can I insert the result of function such as
>
>
> (define (table x)
> (do ((i 0 (+ i 1)))
> ((= i 5))
> (printf "---> ~a\n" (+ i x))))
>
> in a text% editor for instance if I do
> ...
> (define text1 (new text%))
>
> (send text1 insert (format "a\n" (table 3)))
>
> I get the result in drscheme toplevel and #<void> in
> my editor-canvas%
To capture the printed output instead of the function result:
(let ([p (open-output-string)])
(parameterize ([current-output-port p])
(table 3))
(send textl insert (get-output-string p)))
Matthew