home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.forth      Forth programmers eat a lot of Bratwurst      117,927 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 116,479 of 117,927   
   Anton Ertl to dxf   
   Re: HELD   
   09 May 24 15:02:26   
   
   From: anton@mips.complang.tuwien.ac.at   
      
   dxf  writes:   
   >But the idea of sending data to disk using console output   
   >statements seems confusing.   
      
   I have been doing this for many decades without confusion, and I am   
   not the only one.  Lots of shell and awk code works that way.   
      
   >How does the programmer differentiate bona-fide   
   >console output from disk output?   
      
   The typical case is that error messages should go to the console while   
   regular output is directed to disk.  For that purpose Unix has two   
   file descriptors: 1 (stdout as C FILE *), and 2 (stderr as C FILE *).   
   If you want to print an error or warning message, you print to stderr,   
   otherwise to stdout.   
      
   Concerning OUTFILE-EXECUTE in Gforth, you can do the same:   
      
   [~:149311] gforth -e '." data for a file" s" error message" '"'"' type stderr   
   outfile-execute bye' >/tmp/myfile   
   error message[~:149312]   
   [~:149312] cat /tmp/myfile   
   data for a file[~:149313]   
      
   You can also do a STDERR OUTFILE-EXECUTE in a definition that is   
   executed by OUTFILE-EXECUTE (i.e., where the other TYPEs are   
   redirected to some file, or (probably less common) interleave plain   
   TYPEs with calls to OUTFILE-EXECUTE.  E.g.,   
      
   s" /tmp/myfile" w/o open-file throw constant myfile   
   : foo ." data for myfile" cr ;   
   ' foo myfile outfile-execute   
   .( "bona-fide" console output) cr   
      
   - anton   
   --   
   M. Anton Ertl  http://www.complang.tuwien.ac.at/anton/home.html   
   comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html   
        New standard: https://forth-standard.org/   
      EuroForth 2023: https://euro.theforth.net/2023   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca