|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
procedure LINE_CMPControlText(Count1,Count2:integer;TR1,TR2:TRichEdit;StructInfo1,StructInfo2:array of StructInfomation;var MatchInfo:array of MatchInfomation);
//5//对比两控件各行,选择匹配最当,记录在MatchInfo数组中
var
Str1,Str2:string;
i1,i2,i:integer;//循环变量
Length1,length2:integer;
N:integer;//匹配成功个数
percent:integer;
TempInfo: array of TempInfomation;//临时数组
begin
i1:=1;
SetLength(TempInfo,Count2);//设置临时数组长度(保存与TR2各行匹配的信息)
while(i1<=count1) do
begin
Str1:=StructInfo1[i1].lstring;
Length1:=length(Trim(Str1));
//ShowMessage(Str1);
for i2:=1 to Count2 do
//此循环匹配Str1与TR2各行,并将信息填入TempInfo数组中,为下一个For铺垫
begin
Str2:=StructInfo2[i2].lstring;
length2:=length(Trim(Str2));
N:=LINE_CompareString(Str1,Str2);
if(length1>=length2)then
percent:=Trunc(N*100/length1)
else percent:=Trunc(N*100/length2);
TempInfo[i2].Number:=N;//为临时数组赋值
TempInfo[i2].percent:=percent;
end;
MatchInfo[i1].percent:=TempInfo[1].percent;//For循环前赋初值
MatchInfo[i1].TR1Line:=i1;
MatchInfo[i1].TR2Line:=1;
MatchInfo[i1].MatchNumber:=TempInfo[1].Number;
for i:=1 to count2 do
//选择percent最大项,赋予MatchInfo数组
begin
if(TempInfo[i].percent=100)then
//如果匹配比为100,则直接赋值跳出
begin
MatchInfo[i1].TR1Line:=i1;
MatchInfo[i1].TR2Line:=i;
MatchInfo[i1].MatchNumber:=TempInfo[i].Number;
MatchInfo[i1].Percent:=TempInfo[i].percent;
break;
end;
if(i<=count2-1)then
begin
if(TempInfo[i].percent<TempInfo[i+1].Percent)then
begin
MatchInfo[i1].percent:=TempInfo[i+1].percent;
MatchInfo[i1].TR2Line:=i+1;
MatchInfo[i1].TR2Line:=i1;
MatchInfo[i1].MatchNumber:=TempInfo[i+1].Number;
end
end
end;
i1:=i1+1;
end;
ShowMessage('ok');
弹出对话框后,异常
end;
|
-
-
|