[Lazarus] Reading and Writing to TProcess

leledumbo leledumbo_cool at yahoo.co.id
Sun Apr 13 06:19:42 CEST 2014


You can do it around here:

nread := Hbk.Output.Read(Buffer^, C_BUFSIZE);
if nread = 0 then
  sleep(100)
else
  begin
    // Translate raw input to a string
    SStream.size := 0;
    SStream.Write(Buffer^, nread);
    // And add the raw stringdata to the memo
    Memo1.Lines.Text := Memo1.Lines.Text + SStream.DataString;
  end;

Instead of directly flushing SStream contents to Memo1, I suggest keep
appending Buffer to SStream and detect the string you're looking for after
SStream.Write. When you've found it (and ensure the process already waits
for input), you can call Hbk.Input.Write methods (it has several overloads,
figure out which one is the best for you). Remember that normally process
waits for newline before processing input, so you might want to append that
to your input data.



--
View this message in context: http://free-pascal-lazarus.989080.n3.nabble.com/Lazarus-Reading-and-Writing-to-TProcess-tp4036656p4036661.html
Sent from the Free Pascal - Lazarus mailing list archive at Nabble.com.




More information about the Lazarus mailing list