Board index » delphi » where can I find this...

where can I find this...


2003-12-12 09:42:49 AM
delphi256
I need to have a Delphi app (D6) spawn off a vanilla win32 .exe file and
display the standard output in a display window. Kinda like running in a DOS
box, but under control of the Delphi app. I know how to spawn the job, but I'm
not sure how to get the output back and displayed in something like a TMemo.
Can somebody please point me to the best place to find this info?
Thx
-David
 
 

Re:where can I find this...

Davids writes:
Quote
Can somebody please point me to the best place to find this info?
Yes.
Check borland.public.attachments for a post "CreateProcess and controlling
the console" by me (07Dec, #7135)
--
Ben
 

Re:where can I find this...

Quote
box, but under control of the Delphi app. I know how to spawn the job,
but I'm
not sure how to get the output back and displayed in something like a
TMemo.

www.pre.demon.co.uk/downloads/console.zip
 

Re:where can I find this...

great help! Thanks!
-David
"Ben Hochstrasser [FF]" writes:
Quote
Davids writes:

>Can somebody please point me to the best place to find this info?

Yes.

Check borland.public.attachments for a post "CreateProcess and controlling
the console" by me (07Dec, #7135)

--
Ben
 

Re:where can I find this...

Great help! Thanks!
-David
Martin Lafferty writes:
Quote
>box, but under control of the Delphi app. I know how to spawn the job,
but I'm
>not sure how to get the output back and displayed in something like a
TMemo.
>

www.pre.demon.co.uk/downloads/console.zip
 

Re:where can I find this...

Hi, Ben
I tried this, as well as the "console" example the other guy referred me to.
They both have the same problem: the output from Windows is apparently being
buffered. For instance, I have got an app that runs and every couple of seconds
it spits a short line to stdout to display its progress. It runs for about 30
seconds. When I run it under both redcon and console, nothing is displayed
until the app terminates, whereupon a couple dozen lines appear all at once.
I'm running this under Delphi 6 in a Windows 2000 Pro environment.
Supposedly, in WinNT (and 2K by analogy), the data is not supposed to be
buffered by Windows. However, there is some mechanism clearly buffering the
stdout data and even chopping it up into some other chunks; ie., every so many
lines, a newline is inserted into a line at some arbitrary place in the middle
of the line. This makes it rather difficult to parse the output and do anything
useful with it.
Do you have any thoughts on what could be causing this strangeness?
Thanks
-David
"Ben Hochstrasser [FF]" writes:
Quote
Davids writes:

>Can somebody please point me to the best place to find this info?

Yes.

Check borland.public.attachments for a post "CreateProcess and controlling
the console" by me (07Dec, #7135)

--
Ben
 

Re:where can I find this...

Davids writes:
Quote
Supposedly, in WinNT (and 2K by analogy), the data is not supposed to
be buffered by Windows. However, there is some mechanism clearly
buffering the stdout data and even chopping it up into some other
chunks; ie., every so many lines, a newline is inserted into a line at
some arbitrary place in the middle of the line. This makes it rather
difficult to parse the output and do anything useful with it.
First of all - there are two output channels: STDOUT and STDERR which
usually both are redirected to the console. So...how do STDOUT and STDERR
look like? ("yourprogram.exe>output.txt 2>error.txt")
Then, many console applications don't strictly use only STDOUT and the
like, they play with cursor positions and the like (remember old Pascal's
CRT unit?), eg to display a progress message etc. one could write
while i < 100 do
begin
write(#13, i, '% done...');
do_something_useful;
inc(i);
end;
The output of this looks fine on the screen but horrible on the caught
output.
Then, my RedCon unit is constantly polling stdin, stdout and stderr to
see if there's any work to do. Of course, some loops take longer than
others, and a bunch of characters accumulate in the output buffers - you
get 'chunky' output.
I don't quite understand the interspersed newline characters - at least
in theory the caught stdout and stderr should look the same as if they
had been redirected to files on the command line. Can you post an example
(both RedCon results and cmdline output?)
--
Ben
 

Re:where can I find this...

Davids writes:
Quote
Supposedly, in WinNT (and 2K by analogy), the data is not supposed to
be buffered by Windows. However, there is some mechanism clearly
buffering the stdout data and even chopping it up into some other
chunks; ie., every so many lines, a newline is inserted into a line at
some arbitrary place in the middle of the line. This makes it rather
difficult to parse the output and do anything useful with it.
First of all - there are two output channels: STDOUT and STDERR which
usually both are redirected to the console. So...how do STDOUT and STDERR
look like? ("yourprogram.exe>output.txt 2>error.txt")
Then, many console applications don't strictly use only STDOUT and the
like, they play with cursor positions and the like (remember old Pascal's
CRT unit?), eg to display a progress message etc. one could write
while i < 100 do
begin
write(#13, i, '% done...');
do_something_useful;
inc(i);
end;
The output of this looks fine on the screen but horrible on the caught
output.
Then, my RedCon unit is constantly polling stdin, stdout and stderr to
see if there's any work to do. Of course, some loops take longer than
others, and a bunch of characters accumulate in the output buffers - you
get 'chunky' output.
I don't quite understand the interspersed newline characters - at least
in theory the caught stdout and stderr should look the same as if they
had been redirected to files on the command line. Can you post an example
(both RedCon results and cmdline output?)
Follow-up set to borland.public.delphi.nativeapi
--
Ben
Mach es wie die Eieruhr - zhl die weichen Eier nur!