|
|
unit u_op_seae_difftd;
|
|
|
|
|
|
interface
|
|
|
|
|
|
uses
|
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|
|
Dialogs, bsSkinCtrls, BusinessSkinForm, ExtCtrls, StdCtrls, ComCtrls,
|
|
|
DBCtrls,DB, wwriched, wwrichedspell2000;
|
|
|
|
|
|
type
|
|
|
Tfrm_op_seae_difftd = class(TForm)
|
|
|
bsBusinessSkinForm1: TbsBusinessSkinForm;
|
|
|
bsSkinPanel1: TbsSkinPanel;
|
|
|
bsSkinPanel2: TbsSkinPanel;
|
|
|
Splitter1: TSplitter;
|
|
|
bsSkinButton5: TbsSkinButton;
|
|
|
bsSkinPanel3: TbsSkinPanel;
|
|
|
bsSkinPanel4: TbsSkinPanel;
|
|
|
chgbefore: TDBRichEdit;
|
|
|
chgafter: TDBRichEdit;
|
|
|
bsSkinPanel5: TbsSkinPanel;
|
|
|
Label2: TLabel;
|
|
|
Label1: TLabel;
|
|
|
RichEdit1: TRichEdit;
|
|
|
RichEdit2: TRichEdit;
|
|
|
procedure bsSkinButton5Click(Sender: TObject);
|
|
|
procedure FormShow(Sender: TObject);
|
|
|
private
|
|
|
{ Private declarations }
|
|
|
procedure setdifcolor ;
|
|
|
function replace(str,s1,s2:string):string;
|
|
|
Function After(Src,S:string ) : string ;
|
|
|
Function Before(Src,S:string):string ;
|
|
|
Function middle( Src,S1,S2:string ) : string ;
|
|
|
public
|
|
|
{ Public declarations }
|
|
|
procedure showchgtd(ds1,ds2:TDataSource;fl1:string) ;
|
|
|
end;
|
|
|
|
|
|
var
|
|
|
frm_op_seae_difftd: Tfrm_op_seae_difftd;
|
|
|
|
|
|
implementation
|
|
|
|
|
|
{$R *.dfm}
|
|
|
uses u_main ;
|
|
|
|
|
|
procedure Tfrm_op_seae_difftd.bsSkinButton5Click(Sender: TObject);
|
|
|
begin
|
|
|
close ;
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_op_seae_difftd.setdifcolor;
|
|
|
var i,j,k,count1,count2,min:integer ;
|
|
|
wordat:integer ;
|
|
|
paramstr1,paramstr2,SourceList,DestList,ResultList:Tstringlist ;
|
|
|
tmpstr1,tmpstr2:string ;
|
|
|
tmp:string ;
|
|
|
n0,linex:integer ;
|
|
|
begin
|
|
|
|
|
|
try
|
|
|
Richedit1.Lines.Clear;
|
|
|
paramstr1:=tstringlist.create ;
|
|
|
paramstr2:=tstringlist.Create ;
|
|
|
|
|
|
SourceList:=tstringlist.create ;
|
|
|
|
|
|
DestList:=tstringlist.Create ;
|
|
|
|
|
|
ResultList:=tstringlist.Create ;
|
|
|
|
|
|
|
|
|
paramstr1.Clear;
|
|
|
paramstr2.Clear;
|
|
|
|
|
|
SourceList.Clear;
|
|
|
|
|
|
DestList.Clear;
|
|
|
|
|
|
ResultList.Clear;
|
|
|
|
|
|
|
|
|
paramstr1.Text:=chgbefore.Text; // ¿Í»§È·ÈÏÊý¾Ý
|
|
|
paramstr2.Text:=chgafter.Text; // ±¾µØÊý¾Ý
|
|
|
|
|
|
tmpstr1:='';
|
|
|
for j:=0 to paramstr1.Count-1 do
|
|
|
begin
|
|
|
if tmpstr1='' then
|
|
|
begin
|
|
|
tmpstr1:=StringReplace(trim(paramstr1.Strings[j]), ' ', ' ', [rfReplaceAll]);
|
|
|
end
|
|
|
else
|
|
|
begin
|
|
|
tmpstr1:=tmpstr1+' '+StringReplace(trim(paramstr1.Strings[j]), ' ', ' ', [rfReplaceAll]);
|
|
|
end;
|
|
|
SourceList.Add(StringReplace(trim(paramstr1.Strings[j]), ' ', ' ', [rfReplaceAll]));
|
|
|
end;
|
|
|
|
|
|
tmpstr2:='';
|
|
|
for j:=0 to paramstr2.Count-1 do
|
|
|
begin
|
|
|
if tmpstr2='' then
|
|
|
begin
|
|
|
tmpstr2:=StringReplace(trim(paramstr2.Strings[j]), ' ', ' ', [rfReplaceAll]);
|
|
|
end
|
|
|
else
|
|
|
begin
|
|
|
tmpstr2:=tmpstr2+' '+StringReplace(trim(paramstr2.Strings[j]), ' ', ' ', [rfReplaceAll]);
|
|
|
end;
|
|
|
DestList.Add(StringReplace(trim(paramstr2.Strings[j]), ' ', ' ', [rfReplaceAll]));
|
|
|
end;
|
|
|
|
|
|
if SourceList.Count>=DestList.Count then
|
|
|
begin
|
|
|
for j:=0 to SourceList.Count-1 do
|
|
|
begin
|
|
|
if j<=DestList.Count-1 then
|
|
|
begin
|
|
|
if AnsiCompareStr(DestList.Strings[j] ,SourceList.Strings[j])<>0 then
|
|
|
begin
|
|
|
Richedit1.Lines.Add(SourceList.Strings[j]);
|
|
|
linex:=Richedit1.Lines.IndexOf(SourceList.Strings[j]);
|
|
|
n0:=SendMessage(Richedit1.Handle,EM_LINEINDEX, linex, 0 ); //È¡µÃXÐеÄÊ××Ö·ûÐòºÅ
|
|
|
Richedit1.SelStart:=n0; // Ñ¡ÖÐÕâÒ»ÐÐÎÄ×Ö
|
|
|
Richedit1.SelLength:=length(RichEdit1.Lines.Strings[linex]);
|
|
|
RichEdit1.SelAttributes.color:=clRed; //ÉèΪÐèÒªµÄ×ÖÌå´óС
|
|
|
Richedit2.Lines.Add(DestList.Strings[j]);
|
|
|
end
|
|
|
else
|
|
|
begin
|
|
|
ResultList.Add(SourceList.Strings[j]) ;
|
|
|
Richedit1.Lines.Add(SourceList.Strings[j]);
|
|
|
Richedit2.Lines.Add(DestList.Strings[j]);
|
|
|
end;
|
|
|
end
|
|
|
else
|
|
|
begin
|
|
|
|
|
|
Richedit1.Lines.Add(SourceList.Strings[j]);
|
|
|
linex:=Richedit1.Lines.IndexOf(SourceList.Strings[j]);
|
|
|
n0:=SendMessage(Richedit1.Handle,EM_LINEINDEX, linex, 0 ); //È¡µÃXÐеÄÊ××Ö·ûÐòºÅ
|
|
|
Richedit1.SelStart:=n0; // Ñ¡ÖÐÕâÒ»ÐÐÎÄ×Ö
|
|
|
Richedit1.SelLength:=length(Richedit1.Lines.Strings[linex]);
|
|
|
Richedit1.SelAttributes.color:=clRed; //ÉèΪÐèÒªµÄ×ÖÌå´óС
|
|
|
end;
|
|
|
end
|
|
|
end
|
|
|
else
|
|
|
if SourceList.Count<DestList.Count then
|
|
|
begin
|
|
|
for j:=0 to DestList.Count-1 do
|
|
|
begin
|
|
|
if j<=SourceList.Count-1 then
|
|
|
begin
|
|
|
if AnsiCompareStr(DestList.Strings[j] ,SourceList.Strings[j])<>0 then
|
|
|
begin
|
|
|
Richedit1.Lines.Add(SourceList.Strings[j]);
|
|
|
linex:=Richedit1.Lines.IndexOf(SourceList.Strings[j]);
|
|
|
n0:=SendMessage(Richedit1.Handle,EM_LINEINDEX, linex, 0 ); //È¡µÃXÐеÄÊ××Ö·ûÐòºÅ
|
|
|
Richedit1.SelStart:=n0; // Ñ¡ÖÐÕâÒ»ÐÐÎÄ×Ö
|
|
|
Richedit1.SelLength:=length(RichEdit1.Lines.Strings[linex]);
|
|
|
RichEdit1.SelAttributes.color:=clRed; //ÉèΪÐèÒªµÄ×ÖÌå´óС
|
|
|
|
|
|
Richedit2.Lines.Add(DestList.Strings[j]);
|
|
|
end
|
|
|
else
|
|
|
begin
|
|
|
ResultList.Add(SourceList.Strings[j]) ;
|
|
|
Richedit1.Lines.Add(SourceList.Strings[j]);
|
|
|
|
|
|
Richedit2.Lines.Add(DestList.Strings[j]);
|
|
|
end;
|
|
|
end
|
|
|
else
|
|
|
begin
|
|
|
Richedit2.Lines.Add(DestList.Strings[j]);
|
|
|
linex:=Richedit2.Lines.IndexOf(DestList.Strings[j]);
|
|
|
n0:=SendMessage(Richedit2.Handle,EM_LINEINDEX, linex, 0 ); //È¡µÃXÐеÄÊ××Ö·ûÐòºÅ
|
|
|
Richedit2.SelStart:=n0; // Ñ¡ÖÐÕâÒ»ÐÐÎÄ×Ö
|
|
|
Richedit2.SelLength:=length(Richedit2.Lines.Strings[linex]);
|
|
|
Richedit2.SelAttributes.color:=clRed; //ÉèΪÐèÒªµÄ×ÖÌå´óС
|
|
|
end;
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
finally
|
|
|
paramstr1.Free ;
|
|
|
paramstr2.Free ;
|
|
|
SourceList.Free ;
|
|
|
DestList.Free ;
|
|
|
ResultList.Free ;
|
|
|
end ;
|
|
|
end;
|
|
|
{
|
|
|
procedure Tfrm_op_seae_difftd.setdifcolor;
|
|
|
var i,j,count1,count2,min:integer ;
|
|
|
wordat:integer ;
|
|
|
paramstr1,paramstr2:Tstringlist ;
|
|
|
tmpstr1,tmpstr2:string ;
|
|
|
tmp:string ;
|
|
|
begin
|
|
|
tmpstr1:=StringReplace(chgbefore.Text, ' ', ' ', [rfReplaceAll]) ;
|
|
|
tmpstr2:=StringReplace(chgafter.Text, ' ', ' ', [rfReplaceAll]) ;
|
|
|
if AnsiCompareStr(tmpstr1,tmpstr2)=0 then exit ;
|
|
|
try
|
|
|
paramstr1:=tstringlist.create ;
|
|
|
paramstr2:=tstringlist.Create ;
|
|
|
tmp:=Before(tmpstr1,#13#10) ;
|
|
|
while tmp<>'' do
|
|
|
begin
|
|
|
paramstr1.add(tmp);
|
|
|
tmpstr1:=after(tmpstr1,#13#10);
|
|
|
tmp:=Before(tmpstr1,#13#10) ;
|
|
|
end ;
|
|
|
|
|
|
|
|
|
if tmpstr1<>'' then paramstr1.add(tmpstr1);
|
|
|
tmp:=Before(tmpstr2,#13#10) ;
|
|
|
|
|
|
|
|
|
while tmp<>'' do
|
|
|
begin
|
|
|
paramstr2.add(tmp);
|
|
|
tmpstr2:=after(tmpstr2,#13#10);
|
|
|
tmp:=Before(tmpstr2,#13#10) ;
|
|
|
end ;
|
|
|
if tmpstr2<>'' then paramstr2.add(tmpstr2);
|
|
|
count1:=paramstr1.Count ;
|
|
|
count2:=paramstr2.Count ;
|
|
|
|
|
|
|
|
|
|
|
|
for i:=0 to count1-1 do
|
|
|
begin
|
|
|
tmp:=paramstr1[i] ;
|
|
|
wordat:=pos(tmp,chgafter.Text) ;
|
|
|
if wordat<=0 then
|
|
|
begin
|
|
|
wordat:=0 ;
|
|
|
for j:=0 to i-1 do wordat:=wordat+length(paramstr1[j]);
|
|
|
chgbefore.SelStart:=wordat ;
|
|
|
chgbefore.SelLength:=length(tmp);
|
|
|
chgbefore.SelLength:=length(tmp)+1;
|
|
|
chgbefore.SelAttributes.Color:=clred ;
|
|
|
end ;
|
|
|
end ;
|
|
|
|
|
|
for i:=0 to count2-1 do
|
|
|
begin
|
|
|
tmp:=paramstr2[i] ;
|
|
|
wordat:=pos(tmp,chgbefore.Text) ;
|
|
|
if wordat<=0 then
|
|
|
begin
|
|
|
wordat:=0 ;
|
|
|
for j:=0 to i-1 do wordat:=wordat+length(paramstr2[j]);
|
|
|
chgafter.SelStart:=wordat ;
|
|
|
chgafter.SelLength:=length(tmp)+1;
|
|
|
chgafter.SelAttributes.Color:=clblue ;
|
|
|
end ;
|
|
|
end ;
|
|
|
finally
|
|
|
paramstr1.Free ;
|
|
|
paramstr2.Free ;
|
|
|
end ;
|
|
|
end;
|
|
|
}
|
|
|
|
|
|
procedure Tfrm_op_seae_difftd.showchgtd(ds1, ds2: TDataSource; fl1: string);
|
|
|
begin
|
|
|
chgbefore.DataSource:=ds1 ;
|
|
|
chgbefore.DataField:=fl1 ;
|
|
|
chgafter.DataSource:=ds2 ;
|
|
|
chgafter.DataField:=fl1 ;
|
|
|
showmodal ;
|
|
|
end;
|
|
|
|
|
|
////////////////////////////////////////////////
|
|
|
Function Tfrm_op_seae_difftd.After(Src,S:string ) : string ;
|
|
|
Var F : Word ;
|
|
|
begin
|
|
|
F := POS (s,Src) ;
|
|
|
if F=0 then result:=''
|
|
|
else
|
|
|
result:= COPY(Src , F+1,length(Src)) ;
|
|
|
end ;
|
|
|
|
|
|
//ÌáÈ¡×Ö·û´®ÖÐÖ¸¶¨×Ó×Ö·û´®Ç°µÄ×Ö·û´®
|
|
|
Function Tfrm_op_seae_difftd.Before(Src,S:string):string ;
|
|
|
Var F:Word ;
|
|
|
begin
|
|
|
F := POS (s,Src) ;
|
|
|
if F=0 then result:=''
|
|
|
else
|
|
|
result := COPY(Src,1,F-1) ;
|
|
|
end ;
|
|
|
|
|
|
Function Tfrm_op_seae_difftd.middle( Src,S1,S2:string ) : string ;
|
|
|
Var F1,F2:Word ;
|
|
|
begin
|
|
|
F1:= POS (s1,Src) ;
|
|
|
F2:= POS (s2,Src) ;
|
|
|
if F2<=0 then result:=Src else
|
|
|
result := COPY(Src,F1+1,F2-F1-1) ;
|
|
|
end ;
|
|
|
|
|
|
function Tfrm_op_seae_difftd.replace(str,s1,s2:string):string;
|
|
|
var
|
|
|
i:integer;
|
|
|
s,t:string;
|
|
|
begin
|
|
|
s:='';
|
|
|
t:=str;
|
|
|
repeat
|
|
|
i:=pos(lowercase(s1),lowercase(t));
|
|
|
if i>0 then begin
|
|
|
s:=s+Copy(t,1,i-1)+s2;
|
|
|
t:=Copy(t,i+Length(s1),MaxInt);
|
|
|
end else s:=s+t;
|
|
|
until i<=0;
|
|
|
result:=s;
|
|
|
end;
|
|
|
procedure Tfrm_op_seae_difftd.FormShow(Sender: TObject);
|
|
|
begin
|
|
|
setdifcolor;
|
|
|
end;
|
|
|
|
|
|
end.
|