Board index » delphi » capture output from exec'd program

capture output from exec'd program

Suppose I have this procedure:

procedure Test;
 var
      DumpStuffOnTheScreen : string;
      Parameters           : string;
 begin
      DumpStuffOnTheScreen := 'dumpst~1.exe'
      Paramameters := '';
      exec(DumpStuffOnTheScreen,Parameters);
 end.

What would I have to do to capture the output from DumpStuffOnTheScreen?

Thanks,
Jenny

 

Re:capture output from exec'd program


JRS:  In article <pEyC7.4$Ju6.50...@news.uswest.net>, seen in
news:comp.lang.pascal.borland, Jenny <j...@aol.com> wrote at Sat, 27 Oct
2001 09:26:20 :-

Quote

>What would I have to do to capture the output from DumpStuffOnTheScreen?

See <URL: http://www.merlyn.demon.co.uk/programs/scrcatch.pas>, the J, K
loops, but omit Writeln and make S an array of string [132].

for J := 0 to LastRow do begin
  S := '' ;
  for K := 1 to ScrCols do begin
    C := char(Mem[Sg:Start+2*(ScrCols*J+K-1)]) ;
    S[K] := C ;
    if C<>#32 then S[0] := char(K) ;
    end ;
  Writeln(S) end ;

--
? John Stockton, Surrey, UK.  j...@merlyn.demon.co.uk   Turnpike v4.00   MIME. ?
 Web <URL: http://www.merlyn.demon.co.uk/> - FAQqish topics, acronyms & links.
 PAS, EXE in <URL: http://www.merlyn.demon.co.uk/programs/> - see 00index.txt.
 Do not Mail News to me.    Before a reply, quote with ">" or "> " (SoRFC1036)

Re:capture output from exec'd program


Quote
Jenny <j...@aol.com> wrote in message news:pEyC7.4$Ju6.50402@news.uswest.net...
> Suppose I have this procedure:

> procedure Test;
>  var
>       DumpStuffOnTheScreen : string;
>       Parameters           : string;
>  begin
>       DumpStuffOnTheScreen := 'dumpst~1.exe'
>       Paramameters := '';
>       exec(DumpStuffOnTheScreen,Parameters);
>  end.

> What would I have to do to capture the output from DumpStuffOnTheScreen?

if DumpStuffOnTheScreen uses standard output, you can do...

  exec(GetEnv('COMSPEC'), '/C ' + DumpStuffOnTheScreen + ' ' + Parameters +
    '>CAPTURE.TXT');

to redirect the output to a file.

Re:capture output from exec'd program


Thanks! That's just what I needed.

Jenny

Other Threads