sending output from display to a file 
Author Message
 sending output from display to a file

Hello,

probably another easy one but here goes:

I've written several scheme snippets which reference modules to do things like
calculate the efficiency from the decibels, for example.  The top-level modules
take no arguments and produce output only via display .  I would like to be able
to execute the top-level code and have the output go to a file.  I tried doing,
if I remember correctly (with-output-port (my-code) ) but it complained because
I didn't give it a port.  Is there some way to link a port to a file name that I
can use with this?  Could I do that with pp?

TIA



Sat, 23 Mar 2002 03:00:00 GMT  
 sending output from display to a file
+---------------
| The top-level modules take no arguments and produce output only via display.
| I would like to be able to execute the top-level code and have the output
| go to a file.  I tried doing, if I remember correctly
|   (with-output-port (my-code) )
| but it complained because | I didn't give it a port.
+---------------

Unfortunately, "with-output-port" is not a standard Scheme procedure
(though at least one Scheme implementation provides "with-output-to-port")
Try (with-output-to-file "filename" <thunk>) instead, e.g.:

        % hs
        > (define (top)
            (do ((i 1 (+ i 1)))
                  ((> i 5))
              (display "this is line ")
              (display i)
              (newline)))
        > (with-output-to-file "foo.bar" top)
        > ^D
        % cat foo.bar
        this is line 1
        this is line 2
        this is line 3
        this is line 4
        this is line 5
        %

Or, if you want to mess with ports explicitly, remember that "display",
"write", and "newline" take an optional second argument, a port.

-Rob

-----

Applied Networking              http://reality.sgi.com/rpw3/
Silicon Graphics, Inc.          Phone: 650-933-1673
1600 Amphitheatre Pkwy.         FAX: 650-933-0511
Mountain View, CA  94043        PP-ASEL-IA



Sat, 23 Mar 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Sending output from Clarion Report Writer for windows to a file

2. sending output to a file or to tee.

3. Sending output to stdout and also to a file

4. question about sending output to files

5. How to send output to file

6. How To Output To A File Like Using $display

7. How To Output To A File Like Using $display

8. How To Output To A File Like Using $display

9. Expect: sending a file as one big send string

10. Expect: sending a file as one big send string

11. how print output to screen and output file

12. Outputting info from awk and using the info to name the awk output file

 

 
Powered by phpBB® Forum Software