[fpc-devel] procedure Types
Michael Van Canneyt
michael at freepascal.org
Sat Mar 4 11:29:23 CET 2006
On Sat, 4 Mar 2006, Amir Aavani wrote:
>
>
> I have problem with procedure Types.
> Look at the following code:
>
> TProcedure= procedure (S: String);
> TTest= class
> MyF: TProcedure;
> procedure F1 (S: String);
> procedure F2 (S: String);
> ....
> ...
> end;
>
> TTest.constructor ;
> begin
> MyF:= @F1;
> end;
>
> it says it can't cast "Procedure (S: String); Object" to TProcedure. The
> problem is clear but I don't know
> (can't find) any solution to define TProcedure as a procedure of a class which
> accepts one argument.
Try the following (note the 'of object' in the declaration):
Type
TMyStringProc = procedure (S : String) of object;
and then
MyF : TMyStringProc;
This is documented.
Michael.
More information about the fpc-devel
mailing list