Function Method Pointers in Delphi - ablealias/Delphi GitHub Wiki
Delphi allows you to take the address of a function, procedure or method
and use that address to call the
routine. For the sake of simplicity, all three kinds of pointers are called procedure pointers
. A procedure
pointer has a type that specifies a function’s return type. See the example below,
type
TProcedureType = procedure(Arg: Integer);
TFunctionType = function(Arg: Integer):String;
Var
Proc : TProcedureType; {procedure variable}
Func: TFunctionType;
begin
Proc := ProcedureName;
Proc(12);
end;
You can assign a procedure to a procedure variable directly. You can also use the @ or Addr operators to get the address of a routine
. A common way to test a procedure variable for nil pointer is with in the Assigned
function.