[Lazarus] Tprocess to communicate with applications running
Celâl Emre ÖZ
emre.ozz at gmail.com
Sun Oct 16 18:50:48 CEST 2011
I've tried it but fpc has failed *Project project1.exe raised exception
class external:SIGSEGV *
2011/10/16 Michael Van Canneyt <michael at freepascal.org>
>
>
> 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
> Lazarus at lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20111016/fff5d5e6/attachment-0003.html>
More information about the Lazarus
mailing list