<span id="result_box" class="short_text" lang="en"><span class="hps"><br>I've tried</span> <span class="hps">it but fpc </span></span><span id="result_box" class="short_text" lang="en"><span class="hps">has failed <b>Project project1.exe raised exception class external:SIGSEGV </b><br>
<br></span></span><div class="gmail_quote">2011/10/16 Michael Van Canneyt <span dir="ltr"><<a href="mailto:michael@freepascal.org">michael@freepascal.org</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div><div></div><div class="h5"><br>
<br>
On Sun, 16 Oct 2011, Celâl Emre ÖZ wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Ok. thank u your answer.<br>
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<br>
output or send input when python running.<br>
<br>
Turkish<br>
"Pythonda yazdığım xmpp client yazılımına, pascaldan girdi göndermiyor ya da çıktı alamıyorum.<br>
Tprocess çalışan bir programa program kapanana kadar erişemiyor"<br>
<br>
CODE<br>
<br>
procedure TForm1.Button1Click(Sender: TObject);<br>
var python:TProcess;<br>
cikti:TStringList;<br>
CharBuffer: array [0..511] of char;<br>
ReadCount: integer;<br>
ott:string;<br>
begin<br>
python:=TProcess.Create(nil);<br>
cikti := TStringList.Create;<br>
<br>
python.CommandLine:= 'c:\python27\python.exe jabber.py';<br>
python.Execute;<br>
ShowMessage('b');<br>
while python.Running do begin<br>
ShowMessage('c');<br>
if python.Output.<u></u>NumBytesAvailable >0 then ShowMessage('A'); // ERRORR DON'T SHOW<br>
begin<br>
ReadCount := Min(512, python.Output.<u></u>NumBytesAvailable);<br>
</blockquote>
<br></div></div>
Do not use NumBytesAvailable.<br>
<br>
You can do it simply as follows:<br>
<br>
while python.Running do<br>
begin<br>
Repeat<br>
readCount:=python.Output.Read(<u></u>CharBuffer,512);<br>
Write(ott, Copy(CharBuffer, 0, ReadCount));<br>
memo1.Lines.Add(Copy(<u></u>CharBuffer, 0, ReadCount));<br>
until (readcount<512);<br>
end;<br>
<br>
Read will simply read as much bytes as are available.<br><font color="#888888">
<br>
Michael.</font><br>--<br>
_______________________________________________<br>
Lazarus mailing list<br>
<a href="mailto:Lazarus@lists.lazarus.freepascal.org">Lazarus@lists.lazarus.freepascal.org</a><br>
<a href="http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus" target="_blank">http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus</a><span onmouseout="cancel = false; window.setTimeout(WRCHideContent, 1000); clearTimeout(showTimer);" onmouseover=" var self = this; showTimer = window.setTimeout(function(){WRCShowContent({'rating':{'value':95,'weight':10},'flags':{},'single':true,'ttl':7200,'expireTime':'20111015221238'}, self.className)},600);" class="wrc11" style="padding-right: 16px; width: 16px; height: 16px;"></span><br>
<br></blockquote></div><br>