type
TDisplayerProc = procedure(const s: string);
TIntegerDisplayerFunc = function(const v: integer; dp: TDisplayerProc):
boolean;
procedure Displayer(const s: string);
begin
ShowMessage(s);
end;
function DisplayDoubleInteger(const v: integer; dp: TDisplayerProc): boolean;
var
r: integer;
begin
r := v + v;
dp(IntToStr(r));
result := r > 0;
end;
procedure TForm1.W3Button9Click(Sender: TObject);
var
dp: TDisplayerProc;
idf: TIntegerDisplayerFunc;
begin
dp := Displayer;
dp('hello'); //will "ShowMessage('hello')"
dp('delphi'); //will "ShowMessage('delphi')"
idf := DisplayDoubleInteger; //what will this do?
if idf(-1, dp) then ShowMessage('true') else ShowMessage('false');
if idf(12, dp) then ShowMessage('true') else ShowMessage('false');
end;
|