Como esperar uma função como parâmetro de outra função:


type

   TFunctionParameter = function(const value : integer) : string;

...

function One(const value : integer) : string;
begin
   result := IntToStr(value) ;
end;

function Two(const value : integer) : string;
begin
   result := IntToStr(2 * value) ;
end;

function DynamicFunction(f : TFunctionParameter) : string;
begin
   result := f(2006) ;
end;

...

//Examplo de uso:

var
   s : string;
begin
   s := DynamicFunction(One) ;
   ShowMessage(s) ; //mostra "2006"

   s := DynamicFunction(Two) ;
   ShowMessage(s) ; // mostra "4012"
end;