Question on method pointers

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Question on method pointers

Darius Blaszyk
I have a question regarding the assignment of the result of a function.
The function is declared as such:

TMyFunc = function : extended of Object;

I have a variable that is of this type and I want to assign the result of
this function to a variable of type extended. I was thinking to do it like
this;

var MyFuncVar: TMyFunc;
....
MyResult := MyFuncVar;

But obviously it does not work. On delphi it does, so how can I make it
work on FPC??

Kind regards, Darius Blaszijk

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Question on method pointers

Jonas Maebe-2

On 05 Nov 2005, at 20:21, [hidden email] wrote:

> I have a variable that is of this type and I want to assign the  
> result of
> this function to a variable of type extended. I was thinking to do  
> it like
> this;
>
> var MyFuncVar: TMyFunc;
> ....
> MyResult := MyFuncVar;
>
> But obviously it does not work. On delphi it does, so how can I  
> make it
> work on FPC??

It should work in Delphi mode. In other modes, use

MyResult := MyFunc();

(which also works in Delphi if I'm not mistaken)


Jonas
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Question on method pointers

Darius Blaszyk
It works, thanks

>
> On 05 Nov 2005, at 20:21, [hidden email] wrote:
>
>> I have a variable that is of this type and I want to assign the
>> result of
>> this function to a variable of type extended. I was thinking to do
>> it like
>> this;
>>
>> var MyFuncVar: TMyFunc;
>> ....
>> MyResult := MyFuncVar;
>>
>> But obviously it does not work. On delphi it does, so how can I
>> make it
>> work on FPC??
>
> It should work in Delphi mode. In other modes, use
>
> MyResult := MyFunc();
>
> (which also works in Delphi if I'm not mistaken)
>
>
> Jonas
> _______________________________________________
> fpc-pascal maillist  -  [hidden email]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal