Dear George,

Your method is also very well.

Because using with-output-to-file to wrapper main.rkt is enough, not must 
in every module files.

Thanks.

On Tuesday, April 2, 2019 at 1:30:09 AM UTC+8, gneuner2 wrote:
>
>
> On 4/1/2019 1:09 PM, Siyuan Chen wrote: 
> > Dear George, 
> > 
> > This means we must modify these module code? 
> > 
> > For example: 
> > 
> > suppose in foo.rkt 
> > 
> > #lang racket 
> > (provide ...) 
> > (require ...) 
> > 
> > (define (my-func-1 x) 
> > ...printf..) 
> > 
> > (define (my-func-2 x) 
> >   ...printf..) 
> > 
> > It must be modified to this? 
> > 
> > #lang racket 
> > (provide ...) 
> > (require ...) 
> > 
> > (with-output-to-file <file> 
> >    (lambda () 
> >       (define (my-func-1 x) 
> > ...printf..) 
> > 
> > (define (my-func-2 x) 
> >       ...printf..) 
> >    )) 
> > 
> > It seems not very convenient... 
> > 
> > Is it possible to temporarily change global output port? 
> > 
> > Thanks. 
>
>
> Not exactly.  You don't need to encapsulate the function definitions - 
> just the calls.  IT would be more like the following: 
>
> #lang racket 
> (provide ...) 
> (require ...) 
>
>        (define (my-func-1 x) 
> ...printf..) 
>
> (define (my-func-2 x) 
>        ...printf..) 
>
>
> (with-output-to-file <file> 
>     (lambda () 
>        (my-func-1 ...) 
>        (my-func-2 ...) 
>         ... 
>     )) 
>
>
> But if that still is too heavyweight, the best solution is to run the 
> program from the command line and redirect or tee the output into a 
> file:  e.g., 
>
> racket [flags] program > file 
> or 
> racket [flags] program | tee file 
>
> The exact flags to use depend on the specifics of your program (e.g., is 
> it a script, is it a module, etc.): 
>
> https://docs.racket-lang.org/reference/running-sa.html?q=command%20line#%28part._mz-cmdline%29
>  
>
> Note: Windows doesn't have "tee", but you can do something similar with 
> racket [flags] program > file 2>&1 
>
> 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