Thema: File compare

Einzelnen Beitrag anzeigen

Bjoerk

Registriert seit: 28. Feb 2011
Ort: Mannheim
1.384 Beiträge
 
Delphi 10.4 Sydney
 
#42

AW: File compare

  Alt 24. Mai 2011, 19:39
Sollte funktionieren..
Delphi-Quellcode:
function CompareTextFiles (const file1, file2: string): integer;
var
  s1, s2: string;
  f1, f2: TextFile;
  Count: integer;
begin
  Result:= -1;
  if LowerCase(file1) <> LowerCase(file2) then
  begin
    AssignFile (f1, File1);
    {$I-} Reset(f1); {$I+}
    if IoResult = 0 then
    begin
      AssignFile (f2, File2);
      {$I-} Reset(f2); {$I+}
      if IoResult = 0 then
      begin
        Count:= 0;
        Result:= 0;
        while ((not Eof(f1)) and (not Eof(f2)) and (Result = 0)) do
        begin
          Readln(f1, s1);
          Readln(f2, s2);
          Inc(Count);
          if s1 <> s2 then Result:= Count;
        end;
        if Result = 0 then
          if ((not Eof(f1)) or (not Eof(f2))) then Result:= Count+1;
        closeFile (f2);
      end;
      closeFile (f1);
    end;
  end;
end;
  Mit Zitat antworten Zitat