Delphi-PRAXiS
Seite 3 von 6     123 45     Letzte »    

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Algorithmen, Datenstrukturen und Klassendesign (https://www.delphipraxis.net/78-algorithmen-datenstrukturen-und-klassendesign/)
-   -   File compare (https://www.delphipraxis.net/160642-file-compare.html)

value is NULL 24. Mai 2011 13:42

AW: File compare
 
was passiert aber wenn mehrere lines nicht gleich sind.. result ist doch immer nur 1 Wert?

DeddyH 24. Mai 2011 13:45

AW: File compare
 
Klar, die erste unterschiedliche Zeile. Ansonsten musst Du es halt so umbauen/erweitern, dass eine Liste hinten rauskommt.

value is NULL 24. Mai 2011 14:09

AW: File compare
 
hm habe folgende function:

Delphi-Quellcode:
function FilesEqual(const First, Second: TFilename; out DiffLine: integer): Boolean;
var
  s1, s2: TStringlist;
  i: integer;
begin
  Result := FileExists(First) and FileExists(Second);
  if Result then
    begin
      s1 := TStringlist.Create;
      try
        s1.LoadFromFile(First);
        s2 := TStringlist.Create;
        try
          s2.LoadFromFile(Second);
          i := 0;
              while (i < s1.Count) and (i < s2.Count) do
              begin
                Result := s1[i] = s2[i];
                if not Result then
                  begin
                    DiffLine := i;
                    i := s1.Count;
                    s3.Add(s1[i]);
                  end;
                  inc(i);
                end;
        finally
          s2.Free;
        end;
      finally
        s1.Free;
      end;
    end;
end;
und rufe das auf:

Delphi-Quellcode:
    test_functions.FilesEqual('C:\software.txt','C:\software2.txt',i);
    i2 := 0;
    for i2 := 0 to vlxsysstate_functions.s3.Count -1 do
        Writeln(s3[i2]);
    test_functions.s3.Free;
bekomme aber permanent folgendes:

EStringListError: Listenindex ³berschreitet das Maximum (166)

was ist da falsch?

DeddyH 24. Mai 2011 14:14

AW: File compare
 
Wo kommt denn das s3 in der Funktion jetzt her?

p80286 24. Mai 2011 14:17

AW: File compare
 
und in welcher Zeile tritt der Fehler auf?

Gruß
K-H

und das ist doch nicht Dein Ernst oder?
Delphi-Quellcode:
begin
                    DiffLine := i;
                    i := s1.Count;
                    s3.Add(s1[i]);
                  end;

value is NULL 24. Mai 2011 14:21

AW: File compare
 
s3 ist in meiner test_functions unit deklariert

welche zeile kann ich leider nicht sagen da er sich beim debug bei folgendem aufruf:

Delphi-Quellcode:
test_functions.FilesEqual('C:\software.txt','C:\software2.txt',i);
verabschiedet...

Wieso was ist daran so schlimm?

LG

DeddyH 24. Mai 2011 14:25

AW: File compare
 
Ich habe das ungute Gefühl, dass Du nicht genau weißt, was Du da tust.

[edit] i steht auf Anzahl der Listenelemente, anschließend willst Du diesen nicht existenten Eintrag dann an s3 anhängen. Wie soll das funktionieren? [/edit]

p80286 24. Mai 2011 14:25

AW: File compare
 
Zum einen, empfehle ich das Debuggen mit Hilfe von [F7], zum anderen ist
Delphi-Quellcode:
i:=s1.count;
s3.add(s1[i]);
tödlich.

Gruß
K-H

DeddyH 24. Mai 2011 14:27

AW: File compare
 
Und übergib s3 als Parameter, das ist ja gruselig so.

p80286 24. Mai 2011 14:28

AW: File compare
 
Zitat:

Zitat von DeddyH (Beitrag 1102596)
Und übergib s3 als Parameter, das ist ja gruselig so.

Testen ist auch ohne so etwas gruselig :-)

Gruß
K-H


Alle Zeitangaben in WEZ +1. Es ist jetzt 10:27 Uhr.
Seite 3 von 6     123 45     Letzte »    

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz