Delphi-PRAXiS
Seite 2 von 2     12   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi Probleme mit SetLength (https://www.delphipraxis.net/129803-probleme-mit-setlength.html)

bumpelwumpel 26. Feb 2009 16:24

Re: Probleme mit SetLength
 
Also so weit ich das jetzt alles gelesen habe, ist mein Code ja ziemlicher Müll. :?
Ich werde jetzt nochmal alles überarbeiten und melde mich dann wieder.

edit:

So funktioniert es jetzt. Der Fehler war, dass die 2te if bedingung auch noch in der for-Schleife war.
Points[Line] ist ein String der entweder den Wert 0 hat oder z.B. 34-41.
Delphi-Quellcode:
           Start:=1;
           output:=Textfile.strings[Line];
           for counter1 := 0 to Length(Points[Line])-1 do
           begin
            if Points[Line][counter1]='-' then
              begin
               StartSTR:=Points[Line];
               SetLength(StartSTR, counter1-1); //<--counter1-1 kann nicht -1 ergeben, da die if bedingung bei counter1=0 nicht erfüllt wird
               Start:=StrToInt(StartSTR)-3; //<--Hier musste ich 3 subtrahieren, da später 2 Stellen wegfallen
              end;
           end;
            if (Length(output)>=2) and (output[1]='>') and (output[2]='>') then
              begin
                Delete(output,1,2); //<--Hier werden die 2 Stellen gelöscht
                SetLength(output, Start);
                ListBox1.Items.Add(output);
              end;


Alle Zeitangaben in WEZ +1. Es ist jetzt 06:54 Uhr.
Seite 2 von 2     12   

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