procedure TForm1.Button1Click(Sender: TObject);
begin
 if opendialog1.Execute then
 rich1.Lines.LoadFromFile(opendialog1.FileName );
 label2.Caption := ExtractFilename(opendialog1.FileName) ;
 rich2.Enabled :=false;
end;procedure TForm1.Rich2Change(Sender: TObject);
var
i:integer;
k:integer;
m:integer;
n:integer;
begink:=0;
for i:=1 to length(rich2.Text ) do
begin
    if i<length(rich1.Text)   then
      begin
      rich1.SelStart :=i-2;
      rich1.SelLength :=1;
      rich2.SelStart :=i-2;
      rich2.SelLength :=1;
      edit1.Text :=rich1.SelText ;
      edit2.Text :=rich2.SelText ;
      if rich1.SelText =rich2.SelText   then
         begin
         rich2.SelAttributes.Color :=clgreen;
         k:=k+1;
         end
      else
         rich2.SelAttributes.Color :=clred
       end
    else
    begin
    showmessage('文章录入完成');
    rich2.Enabled :=false;
    timer1.Enabled :=false;
    end;
    label6.Caption :=inttostr(i div 2)+'字';
    if f=0 then m:=0 else m:=trunc((i / f) * 60);
    label4.Caption :=inttostr(m)+ '字/分';
    if i=1 then n:=100 else n:=trunc(k / (i-1) * 100);
    label8.Caption :=inttostr(n)+'%';
    p:=i; end;
 rich2.SelStart :=i;
 rich2.SelLength :=0;
end;procedure TForm1.Button2Click(Sender: TObject);
begin
Rich2.Enabled := True ;
Timer1.Enabled := True ;
end;procedure TForm1.Timer1Timer(Sender: TObject);
begin
f:=f+1;
end;procedure TForm1.FormCreate(Sender: TObject);
begin
rich1.Visible :=false;
rich1.Text :='';
rich2.Text :='';
end;