--- ---
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;
Example usage:
var s: string; begin s := DynamicFunction(One) ; ShowMessage(s) ; //will display "2006" s := DynamicFunction(Two) ; ShowMessage(s) ; // will display "4012" end;