On Sun, 16 Oct 2011, Celâl Emre ÖZ wrote:
Ok. thank u your answer.
I wrote a Python program. It's a xmpp client and it's running like a server. So
it's always run but pascal don't get
output or send input when python running.
Turkish
"Pythonda yazdığım xmpp client yazılımına, pascaldan girdi göndermiyor ya da
çıktı alamıyorum.
Tprocess çalışan bir programa program kapanana kadar erişemiyor"
CODE
procedure TForm1.Button1Click(Sender: TObject);
var python:TProcess;
cikti:TStringList;
CharBuffer: array [0..511] of char;
ReadCount: integer;
ott:string;
begin
python:=TProcess.Create(nil);
cikti := TStringList.Create;
python.CommandLine:= 'c:\python27\python.exe jabber.py';
python.Execute;
ShowMessage('b');
while python.Running do begin
ShowMessage('c');
if python.Output.NumBytesAvailable >0 then ShowMessage('A'); // ERRORR DON'T
SHOW
begin
ReadCount := Min(512, python.Output.NumBytesAvailable);
Do not use NumBytesAvailable.
You can do it simply as follows:
while python.Running do
begin
Repeat
readCount:=python.Output.Read(CharBuffer,512);
Write(ott, Copy(CharBuffer, 0, ReadCount));
memo1.Lines.Add(Copy(CharBuffer, 0, ReadCount));
until (readcount<512);
end;
Read will simply read as much bytes as are available.
Michael.--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus