type
TPositionProc =
procedure
(
const
i:
Integer
);
TForm1 =
class
(TForm)
BitBtn1: TBitBtn;
procedure
BitBtn1Click(Sender: TObject);
private
procedure
Func3(
const
i:
Integer
);
public
Position: TPositionProc;
procedure
SetRange(minVal, maxVal:
Integer
);
end
;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure
Func1(
const
i:
Integer
);
begin
ShowMessage(
'В процедуру 1 передан параметр: '
+ IntToStr(i));
end
;
procedure
Func2(
const
i:
Integer
);
begin
ShowMessage(
'В процедуру 2 передан параметр: '
+ IntToStr(i));
end
;
procedure
TForm1
.
Func3(
const
i:
Integer
);
begin
ShowMessage(
'В процедуру класса передан параметр: '
+ IntToStr(i));
end
;
procedure
TForm1
.
SetRange(minVal, maxVal:
Integer
);
begin
if
maxVal - minVal <
100
then
Position:= Func1
else
if
maxVal - minVal >
100
then
Position:= Func2
else
Position:= @TForm1
.
Func3;
end
;
procedure
TForm1
.
BitBtn1Click(Sender: TObject);
begin
SetRange(
1
,
10
);
Position(
5
);
SetRange(
1
,
105
);
Position(
5
);
SetRange(
1
,
101
);
Position(
5
);
end
;