Mason Wheeler 写了一个非常好的程序来比较字符串列表,但是我不明白如何编写回调程序 TStringCompareProc。有人可以帮我编译吗?
type
TStringCompareProc = procedure(const value: string; const data: TObject) of object;
procedure StringListCompare(List1, List2: TStringList; matchProc: TStringEqualProc;
list1Proc, list2Proc: TStringCompareProc; presorted: boolean = false);
Usage:
procedure TForm1.MatchProc(const value: string; const data: TObject);
// match is found between the two lists
begin
//
end;
procedure TForm1.List1Proc(const value: string; const data: TObject);
// when the first list contains a string not in the second list
begin
//
end;
procedure TForm1.List2Proc(const value: string; const data: TObject);
// when the second list contains a string not in the first list
begin
//
end;
procedure TForm1.Compare1Click(Sender: TObject);
var
MatchProc: TStringEqualProc;
List1Proc: TStringCompareProc;
List2Proc: TStringCompareProc;
iValue: string;
iData: ^PString;
begin
iFinalStringList := StringListCompare(iNewFilesStringList, iExistingFilesStringList,
nil, nil, List1Proc(iValue, @iData), List2Proc(iValue, @iData), False); <- [DCC Error] Unit1.pas(1336): E2010 Incompatible types: 'TStringCompareProc' and 'procedure, untyped pointer or untyped parameter'
end;