I've found a way.

Use (current-output-port out).

On Tuesday, April 2, 2019 at 1:02:05 AM UTC+8, gneuner2 wrote:
>
>
> On 4/1/2019 12:54 PM, Chansey wrote: 
> > My racket project consists of several module files (e.g.: "foo.rkt", 
> > "bar.rkt", ...). 
> > 
> > The entry module file is "main.rkt" 
> > 
> > These files call "printf" in different places of the code (But 
> > "printf" only can print messages to REPL). 
> > 
> > My question is: 
> > 
> > Is there any way to redefine "printf" in main.rkt in order to print 
> > messages to a file? 
>
> "printf"  doesn't write to the REPL per se - it writes to the current 
> output port (which may lead to the REPL).  Depending on how your code is 
> structured, it may be as easy as: 
>
> (with-output-to-file <file> 
>    (lambda () 
>        ... ;; your code here 
>    )) 
>
> Another choice is to use fprintf which allows to choose the output 
> destination. 
>
> George 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to