[fpc-pascal] Class procedure assigned to object's event

Graeme Geldenhuys graemeg.lists at gmail.com
Tue May 26 16:09:05 CEST 2009


2009/5/26  <a.sanguigni at gmail.com>:
>
> if cbOnStatusCMD.Checked then
>    FTP.OnStatus:=callback.StatusCMD
>  else
>    FTP.OnStatus:=nil;
>
> compile fine.
> But if I set {$mode objfpc} rather than delphi I got:
>
> main.pas(262,3) Error: Wrong number of parameters specified for call to
> "StatusCMD"


You need to assign the address of that method in objfpc mode using the @ syntax.

    FTP.OnStatus:=callback. at StatusCMD
or was it...
    FTP.OnStatus:=@callback.StatusCMD

Something like that. I can never remember which. ;-)


> Is there a way to compile with objfpc or better which is the difference
> between two modes for this case ?

I prefer objfpc mode as it's a lot stricter than delphi mode. But if
you work on shared code projects that must compile under Delphi and
FPC, it is just easier (and cleaner) to use delphi mode. Otherwise you
sit with a lot of {$IFDEF FPC} entries.


Regards,
  - Graeme -


_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/



More information about the fpc-pascal mailing list