Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi Frage zu Dynamischem Array (https://www.delphipraxis.net/14867-frage-zu-dynamischem-array.html)

Pseudemys Nelsoni 17. Jan 2004 04:30


Frage zu Dynamischem Array
 
moin,

ich habe mein Typ/array folgendermassen:

Delphi-Quellcode:
type
  TNickInfo = Record
                nick: string;
                ClanID: string;
                LongIP: string;
              end;
Delphi-Quellcode:
var
  NickInfo: Array of TNickInfo;

dann parse ich das ganze:

Delphi-Quellcode:
      begin
        Delete(params, 1, Pos(':', params)+1);
        Trim(params);
        while params <> '' do
        begin
          if Pos(' ', params) > 0 then
          begin
            SetLength(NickInfo, high(NickInfo)+1);
            NickInfo[high(NickInfo)].Nick := Copy(params, 1, Pos(',', params)-1);
            Delete(params, 1, Pos(',', params));
            NickInfo[high(NickInfo)].ClanID := Copy(params, 1, Pos(',', params)-1);
            Delete(params, 1, Pos(',', params));
            NickInfo[high(NickInfo)].LongIP := Copy(params, 1, Pos(' ', params)-1);
            Delete(params, 1, Pos(' ', params));
          end
          else
          begin
            SetLength(NickInfo, high(NickInfo)+1);
            NickInfo[high(NickInfo)].Nick := Copy(params, 1, Pos(',', params)-1);
            Delete(params, 1, Pos(',', params));
            NickInfo[high(NickInfo)].ClanID := Copy(params, 1, Pos(',', params)-1);
            Delete(params, 1, Pos(',', params));
            NickInfo[high(NickInfo)].LongIP := Copy(params, 1, Pos('', params)-1);
            Delete(params, 1, Pos('', params));
          end;
        end;
      end;

der string der da geparsed wird heisst:

Zitat:

:ts.cncreloaded.net - 353 - silentx * #Lob_18_0 :silentx,1163,3576143035 tibfantom,0,408781727 @silent,1294,3576143035 Uzi,1023,1141775833 @HelpBot,0,0

aber irgendwie krieg ich sobald das parsen anfängt eine ZV(EAccessViolation) bei adresse 00irgendwas.


was ist denn daran verkehrt?

SirThornberry 17. Jan 2004 08:54

Re: Frage zu Dynamischem Array
 
in welcher zeile genau kommt der Fehler?

SirThornberry 17. Jan 2004 08:59

Re: Frage zu Dynamischem Array
 
Der Fehler liegt an deinem verwenden von "high"
Wenn die Länge des Arrays 0 ist gibt high -1 zurück
machs lieber so
SetLength(NickInfo, length(NickInfo)+1);
oder
SetLength(NickInfo, high(NickInfo)+2);

Pseudemys Nelsoni 17. Jan 2004 09:20

Re: Frage zu Dynamischem Array
 
hoi

das wusst ich ja nicht, der fehler kam irgendwie bei der untersten zeile von:

Delphi-Quellcode:
begin
  Application.Initialize;
  Application.Title := 'Tiberian Sun - CNC:R - Chat v1.0';
  Application.CreateForm(TForm1, Form1);
  Application.CreateForm(TForm2, Form2);
  Application.CreateForm(TForm3, Form3);
  Application.CreateForm(TForm5, Form5);
  Application.Run;  // hier
end.
mit dem High hast du recht, muss ich nachher mal probieren wenn der server wieder geht, danke :)


Alle Zeitangaben in WEZ +1. Es ist jetzt 05:42 Uhr.

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