[fpc-pascal]How to call a variable of a procedural type?
Peter Vreman
peter at freepascal.org
Sat Oct 26 13:13:44 CEST 2002
At 05:47 26-10-2002, you wrote:
>Hello, every body
>
> I write codes as the following:
>
> >>>>>>>>
>type TFunc = function : integer;
>
>function myfunction:integer;
>begin
> Result:=100;
>end;//myfunction:
>
>var
> fun : TFunc;
> a : integer;
>begin
> fun:=TFunc;
> a:=fun; //@1
> writeln(fun); //@2
>end.
>
><<<<<<<<
>
>
> When I compile it, compiler report that at line of "@1" there's an error.
>But when I comment the line of "@1", the line of "@2" can work well.
>
> I don't know how to return the value of a procedural function variable.
> Can
>anybody tell me that? And tell me what's the different of lines between "@1"
>and "@2".
the writeln(fun) calls function fun() and writes the result of the function.
you should use the following code:
a:=@fun;
writeln(longint(@fun));
Peter
More information about the fpc-pascal
mailing list