On 06/21/2013 03:01 AM, Ivanko B wrote:
> What does not work? *Please* be more verbose!
> =================
> GDB doen't stop at any BP within any method in the datamodule PAS-file
> so me can't get what the program does.
>
> If you simply want to get the output of a self terminating sub process
> use one of the getprocessoutput() functions of mseprocess.pas.
> ===========
> Not an universal solution. With this approach it's difficult to filter
> process stdout per-line as a line is available.
>
I don't know if this is useful / helpful to you or not, but this is 
something I did.
You might be able to adapt it to your needs.

var
   I : integer;
   BytesRead : integer;
   M: TMemoryStream;
   P: TProcess;
   slResult : tstringlist;

begin

M := TMemoryStream.Create;
BytesRead := 0;
P := TProcess.Create(nil);
p.executable := '/path/program/';

p.parameters.add ('add any needed parameters');

P.Options := p.options + [poUsePipes];
P.Execute;

while P.Running
do begin
       if P.Output.NumBytesAvailable > 0
       then begin
         // make sure we have room
         M.SetSize(BytesRead + READ_BYTES);

          // try reading it
          i := P.Output.Read((M.Memory + BytesRead)^, READ_BYTES);
          if i > 0
          then begin
             Inc(BytesRead, i);
          end;
       end;
       Sleep(250);     // wait for some more output
end;

// read last part
repeat
     // make sure we have room
     M.SetSize(BytesRead + READ_BYTES);
     // try reading it
     i := P.Output.Read((M.Memory + BytesRead)^, READ_BYTES);
     if i > 0
     then begin
        Inc(BytesRead, i);
     end;
until i <= 0;

M.SetSize(BytesRead);

// load the stringlist from memorystream
slResult.LoadFromStream(M);

P.Free;
M.Free;


------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
mseide-msegui-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk

Reply via email to