blob: 727ea2928837492f8906da464d99dabc1ec255a6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
{$mode tp}
type ProcType = procedure(s:string);
GetProcType = function(s:string;var Proc:ProcType):boolean;
var ProcVar : ProcType;
GetProcVar : GetProcType;
procedure Default(s:string);
begin
writeln('This is Default:',s);
end;
procedure Proc1(s:string);
begin
writeln('This is Proc1:',s);
end;
procedure Proc2(s:string);
begin
writeln('This is Proc2:',s);
end;
function GetProc(s:string;var ProcVar:ProcType):boolean;
begin
if s='Proc1' then begin
ProcVar:=Proc1;
GetProc:=true;
end
else
if s='Proc2' then begin
ProcVar:=Proc2;
GetProc:=true;
end
else begin
ProcVar:=Default;
GetProc:=false;
end;
end;
begin
GetProcVar:=GetProc;
if GetProcVar('Proc1',ProcVar) then
ProcVar('ok')
else
halt(1);
if GetProcVar('Proc2',ProcVar) then
ProcVar('ok')
else
halt(1);
if GetProcVar('xyz',ProcVar) then
halt(1)
else
writeln('ok');
end.
|