[Lazarus] KOL socketclient object

User usuarioanonimomysql at gmail.com
Wed Dec 10 00:10:15 CET 2008


The solution:

Delphi mode is used for MCK generated source files.

Assign event without @
Conexion.OnError := OnEr;

2008/12/9 User <usuarioanonimomysql at gmail.com>

> I can´t assign the callbacks:
>
> { KOL MCK } // Do not remove this line!
> {$DEFINE KOL_MCK}
> {$ifdef FPC} {$mode delphi} {$endif}
> unit ModuloDatos2;
>
> interface
>
> uses Windows, Messages, KOL {place your units here->}, lNet
> {$IFDEF LAZIDE_MCK}, Forms, mirror, Classes, Controls, mckCtrls, mckObjs,
> Graphics;
> {$ELSE} ; {$ENDIF}
>
> type
>   { TForm3 }
>   {$I MCKfakeClasses.inc}
>   {$IFDEF KOLCLASSES} TForm3 = class; PForm3 = TForm3; {$ELSE OBJECTS}
> PForm3 = ^TForm3; {$ENDIF CLASSES/OBJECTS}
>   TForm3 = {$IFDEF KOLCLASSES}class{$ELSE}object{$ENDIF}({$IFDEF
> LAZIDE_MCK}TForm{$ELSE}TObj{$ENDIF})
>     Form: PControl;
>     KOLForm3: TKOLForm;
>     procedure KOLForm3BeforeCreateWindow(Sender: PObj);
>     procedure OnDs(aSocket: TLSocket);
>     procedure OnRe(aSocket: TLSocket);
>     procedure OnEr(const msg: string; aSocket: TLSocket);
>   private
>     { private declarations }
>   public
>     { public declarations }
>     Conexion: TLTcp;
>   end;
>
> var
>   Form3 {$IFDEF KOL_MCK} : PForm3 {$ELSE} : TForm3 {$ENDIF} ;
>
> {$IFDEF KOL_MCK}
> procedure NewForm3( var Result: PForm3; AParent: PControl );
> {$ENDIF}
>
> implementation
>
> {$IFDEF KOL_MCK}
> {$I modulodatos2_1.inc}
> {$ENDIF}
>
> { TForm3 }
>
> procedure TForm3.KOLForm3BeforeCreateWindow(Sender: PObj);
> begin
>   Conexion := TLTCP.Create(nil); // create new TCP connection with no
> parent component
>   Conexion.OnError := @OnEr; // assign callbacks
>   Conexion.OnReceive := @OnRe;
>   Conexion.OnDisconnect := @OnDs;
>   Conexion.Timeout := 100; // responsive enough, but won't hog cpu
>   ShowMessage('Componente para la conexión creado');
> end;
>
> procedure TForm3.OnDs(aSocket: TLSocket);
> begin
>   ShowMessage('Lost connection');
> end;
>
> procedure TForm3.OnRe(aSocket: TLSocket);
> var
>   s: string;
> begin
>   if aSocket.GetMessage(s) > 0 then
>     ShowMessage(s);
> end;
>
> procedure TForm3.OnEr(const msg: string; aSocket: TLSocket);
> begin
>   ShowMessage(msg); // if error occured, write it
> end;
>
> initialization
> {$IFNDEF KOL_MCK} {$I modulodatos2.lrs} {$ENDIF}
>
> end.
>
> I get the error:
>
> ModuloDatos2.pas(48,28) Error: Variable identifier expected
>
> Anybody help me?
> Best regards.
>
> 2008/11/12 Bogusław Brandys <brandys at o2.pl>
>
>> Aleš Katona pisze:
>> > lNetComponents is the "visual" lNet package and it tries to make a
>> LCLEventer which tries to integrate into LCL/widgetset main loop (see my
>> callaction note from before).
>> >
>> > Obviously this will fail without LCL, although I'd expect a compile-time
>> error, not a runtime error.
>> >
>> > If you get the time, can you give me a backtrace? lNetComponents uses
>> the lclnet unit which depends on LCL units so it shouldn't have compiled.
>> >
>>
>>
>> Try to use synapse library  ported to KOL.
>>
>>
>> Boguslaw
>> _______________________________________________
>> Lazarus mailing list
>> Lazarus at lazarus.freepascal.org
>> http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20081210/7334b18a/attachment-0007.html>


More information about the Lazarus mailing list