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

2009-05-27 Thread Micha Nelissen

Antonio Sanguigni wrote:

For the second one:
main.pas(261,19) Error: Incompatible types: got ""
expected ""


Remove the 'class' keyword from your function. A class method is a 
different beast (with different signature) from a regular method.


Micha
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


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

2009-05-26 Thread JoshyFun
Hello FPC-Pascal,

Tuesday, May 26, 2009, 4:03:00 PM, you wrote:

asgc> class procedure callback.StatusCMD(Sender: TObject; Response: Boolean;
asgc>  const Value: string);
[...]
asgc> Is there a way to compile with objfpc or better which is
asgc> the difference between two modes for this case ?

I may be wrong, but "class procedure" and "of object" may be
incompatible even when the "class procedure" should be the same as a
regular "of object" one with an implicit nil passed.

Which FPC version are you using ?

-- 
Best regards,
 JoshyFun

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


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

2009-05-26 Thread Antonio Sanguigni
2009/5/26 JoshyFun :
> I may be wrong, but "class procedure" and "of object" may be
> incompatible even when the "class procedure" should be the same as a
> regular "of object" one with an implicit nil passed.

Well I really don't know :) but searching on internet for delphi I
found this as a simple way to assign procedure of object to object's
event methods.

> Which FPC version are you using ?

I'm using 2.3.1 but I tried with 2.2.5 too and I have the same thing.

Antonio

-- 
Antonio Sanguigni alias slapshot
--
GioveLUG (Linux User Group) - http://www.giovelug.org
Edupup (Educational distro) - http://www.pieroni.biz/edupup
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


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

2009-05-26 Thread Antonio Sanguigni
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Graeme Geldenhuys wrote:
 > You need to assign the address of that method in objfpc mode using
the @ syntax.
> 
> FTP.OnStatus:=callba...@statuscmd
> or was it...
> FTP.OnStatus:=...@callback.statuscmd
> 
> Something like that. I can never remember which. ;-)

Well I already tried it. For the first one I got:
main.pas(261,28) Fatal: Syntax error, "identifier" expected but "@" found

For the second one:
main.pas(261,19) Error: Incompatible types: got ""
expected ""

> I prefer objfpc mode as it's a lot stricter than delphi mode. But if

Me too ;).

> 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.

Oh yes, that's not a problem. Just setting delphi mode is ok for me. I
was curios to better understand fpc behaviour.

Thanks
Antonio
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkob+WoACgkQYSsm1R1/E7wBMgCfdXAtfgTvWNFsxPZXbAwjqCSi
DPYAoONBGI0Htpnj/+gPkXEX20H3vvYb
=H7dQ
-END PGP SIGNATURE-
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


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

2009-05-26 Thread Graeme Geldenhuys
2009/5/26  :
>
> 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:=callba...@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/
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


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

2009-05-26 Thread a . sanguigni

Hi all,

I'm working on a code I have found on internet about a little ftp client using 
synapse. This code:

class procedure callback.StatusCMD(Sender: TObject; Response: Boolean;
 const Value: string);

defines a class procedure that in delphi mode assigned to:

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"

I think because synapse source has delphi mode on.

The following is the type of OnStatus event:

TFTPStatus = procedure(Sender: TObject; Response: Boolean;
   const Value: string) of object;
 
Is there a way to compile with objfpc or better which is the difference between 
two modes for this case ?

Thanks
Antonio


--
Antonio Sanguigni alias slapshot
--
GioveLUG (Linux User Group) - http://www.giovelug.org
Edupup (Educational distro) - http://www.pieroni.biz/edupup



signature.asc
Description: OpenPGP digital signature
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal