Re: Redirection of output

new topic     » goto parent     » topic index » view thread      » older message » newer message

Hello Derek,

> I'm not sure if this is what you are after , but I tend to do this sort of
> thing...

>   if platform() != WIN32 then
>     puts(2, "Press any key...")
>     junk = wait_key()   
>   end if

no, this is not what I'm after.

When I have a program "myprog.exw" that does some console output, then
I want it to be able to detect, whether the user had called it this way:
   exw.exe myprog.exw

or that way:
   exw.exe myprog.exw > myoutput.txt

I know that this is possible, because there are other programming
languages with built-in functions for this purpose. Please see also my
reply to Pete.

Thanks and best regards,
   Juergen








>> -----Original Message-----
>> From: Juergen Luethje [mailto:jluethje at gmx.de]
>> Sent: Monday, 1 July 2002 15:39
>> To: EUforum
>> Subject: Redirection of output
>> 
>> 
>> 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

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu