![]() |
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:
aber irgendwie krieg ich sobald das parsen anfängt eine ZV(EAccessViolation) bei adresse 00irgendwas. was ist denn daran verkehrt? |
Re: Frage zu Dynamischem Array
in welcher zeile genau kommt der Fehler?
|
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); |
Re: Frage zu Dynamischem Array
hoi
das wusst ich ja nicht, der fehler kam irgendwie bei der untersten zeile von:
Delphi-Quellcode:
mit dem High hast du recht, muss ich nachher mal probieren wenn der server wieder geht, danke :)
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. |
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