Redirection of output
- Posted by Juergen Luethje <jluethje at gmx.de> Jun 30, 2002
- 421 views
Hello all, how can a windows program detect, whether it's output has been redirected to a file? Normally, when I want to see the output of puts(1, ...), I must add wait_key() or something similar to the code. Then I have the following code, for instance: ---------------------------------------------------------- include get.e integer junk puts(1, "Hello World!\n\n") puts(2, "Press any key...") junk = wait_key() ---------------------------------------------------------- When the output is redirected, the statements puts(2, "Press any key...") junk = wait_key() are not useful. It would be very helpful, to have a function for this, so that the code could be written as: ---------------------------------------------------------- include get.e integer junk puts(1, "Hello World!\n\n") if not output_redirected() then puts(2, "Press any key...") junk = wait_key() end if ---------------------------------------------------------- Can anyone help? Thanks in advance, Juergen