iba...@nospamossystems.co.uk
To reply, please remove nospam from the above address.
Web: http://www.ossystems.co.uk
Ian -- I've forgotten how these files are supposed to work...
It used to be, in Pascal, that 'output' was the text that went
to the output file identified by the overridden parameter
on the command line. (Too arcane to go into now)
There was no 'stderr', unless it was
provided by the OS. I presume stderr is the file
on your system that you want stuff to appear in
on the screen?
I'm sure there'll be other suggestions; how about
writing all the stderr stuff to a TStringList. Instead of using
writeln, use TS.Add(s). Display it in a Listbox.
Hope this doesn't sound like Taelon.
--
Grace + Peace | Peter N Roth | Engineering Objects Int'l
Now shipping version 4 of ClassBuilder++
Visit our website at http://www.inconresearch.com/eoi
"Random numbers are too important to be left to chance." - anon
see the api functions getstdhandle() <- which returns either a handle for
stdin, stdout, or stderr.
and setstdhandle() which allows you to redirect the handle associated with
stdin, stdout, and stderr (then subsequent calls to getstdhandle() will
return the appropriate handle)
-dave
djl@tiptec@h.com
remove the second @
the Win32 API has a function get the standard file handles:
hStderr := GetStdHandle( STD_ERROR_HANDLE );
Getting a Delphi Textfile variable to use this handle requires a bit of
unpleasant digging into the entrails of the file variables. You can do it
this way:
Var
stderr: Textfile;
Begin
WriteLn;
// essential to write something to stdout, otherwise output will
// not be open!
Move( output, stderr, Sizeof( stderr ));
TTextRec( stderr ).Handle := GetStdhandle( STD_ERROR_HANDLE );
WriteLn( stderr, 'Bad, bad app!' );
There is no need to close this handle, as far as i'm aware.
Peter Below (TeamB) 10011...@compuserve.com)
Still... I keep learning!
What would be a reason to use these std files?
Peter Below (TeamB) 10011...@compuserve.com)
yes, and (at least in a unix environment) the buffer for stderr was
guaranteed to output to your tty (screen) (ie it was like implicitly calling
flush after every write). so, if your program terminated abnormally, you
would see _all_ data that you wrote to stderr, but not necessarily all data
written to stdout... you might even have code that wrote to stdout first
then some code that wrote to stderr later and you might see the stderr
output first.
--
>There was no 'stderr', unless it was
>provided by the OS. I presume stderr is the file
>on your system that you want stuff to appear in
>on the screen?
>
Peter,
I have managed to do this by using GetStdHandle
MyHandle := GetStdHandle(STD_ERROR_HANDLE);
WriteFile(MyHandle, PChar(MyStr)^, StrLen(PChar(MyStr)),
lngBytesWritten, nil);
>Peter Below <10011...@compuserve.com> wrote in message ...
>
>Still... I keep learning!
>
>What would be a reason to use these std files?
My reason is that I am writing an autoresponder program for our mail
server. The mail server software provides a way of writing data such
as mail headers via STDERR and STDOUT.
All the best... I am continually amazed at the ingenuity
I see displayed in these ngs.