Autor Beitrag
LonghornUser
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 796



BeitragVerfasst: Mi 22.02.06 23:37 
Hallo,

ich habe da mal wieder eine Frage:
Ich habe mittels
ausblenden Delphi-Quelltext
1:
Stringlisten: array of TStringlist;					

ein Feld von Stringlisten erstellt. Ich brauche das, weil die Stringlisten zur Laufzeit erstellt werden sollen.
Jetzt möchte ich eine Stringlist erstellen in dem Feld mittels:
ausblenden Delphi-Quelltext
1:
Stringlisten[0] := TStringlist.Create;					


Ich bekomme aber nur eine Zugriffsverletzung. Was mache ich falsch ?

Ciao LHUser

Moderiert von user profile iconChristian S.: Code- durch Delphi-Tags ersetzt
Grishnak
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 221

Windows XP Home
Delphi 7 PE, Delphi 2005 PE
BeitragVerfasst: Mi 22.02.06 23:46 
Hast du vorher per "SetLength()" die Array-Größe eingestellt?

_________________
Mach' etwas idiotensicher und irgendjemand erfindet einen besseren Idioten!
LonghornUser Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 796



BeitragVerfasst: Mi 22.02.06 23:50 
Nein, da die ARRAY-Größe unbegrenzt sein soll. Es soll so eine Art dynamisches Array sein, welches der Benutzer erweitern können soll. Was mache ich denn falsch ?
Grishnak
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 221

Windows XP Home
Delphi 7 PE, Delphi 2005 PE
BeitragVerfasst: Mi 22.02.06 23:51 
Bevor du das Array benutzen kannst, musst du aber eine Größe festlegen! Natürlich kannst du die auch später wieder ändern (evtl. .Create- oder .Free-Aufrufe aber nicht vergessen!).

Alternative: TObjectList

_________________
Mach' etwas idiotensicher und irgendjemand erfindet einen besseren Idioten!
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Mi 22.02.06 23:52 
Du musst während der Laufzeit die Array-Größe mit SetLength festlegen. Du kannst ein Array dann auch hinterher noch verlängern, bist da also flexibel, aber die Länge musst Du schon bestimmen.

Schau Dir das mal in der Delphi-Doku oder in meinen Crashkurs an. :-)

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Do 23.02.06 00:35 
Hallo,

oder Du baust dir sowas wie TStringList(oder TList) of TStringList.

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )