Autor Beitrag
Seraph
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 163

Windows.:siXPack:.
Delphi7 Professional
BeitragVerfasst: Mo 23.01.06 17:45 
Hi Leute und DelphiFreakse!

Ist es möglich, ein nicht festgelegtes Array von Objekten zu erstellen?

z.B.:
ausblenden Delphi-Quelltext
1:
GroupBoxes: Array of TGroupBox;					


Wenn ja, wie? Auf diese Weise geht es jedenfalls nicht bei mir!

Danke im Voraus
Seraph


Moderiert von user profile iconGausi: Topic aus Sonstiges (Delphi) verschoben am Mo 23.01.2006 um 17:48
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Mo 23.01.06 17:47 
Das sollte eigentlich so gehen. Wo kommt denn der Fehler, und was für einer?

_________________
We are, we were and will not be.
Seraph Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 163

Windows.:siXPack:.
Delphi7 Professional
BeitragVerfasst: Mo 23.01.06 17:51 
Unsigned Array mit 'TGroupBox' ist nicht möglich!
Seraph Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 163

Windows.:siXPack:.
Delphi7 Professional
BeitragVerfasst: Mo 23.01.06 17:54 
Das coole ist - hab ich grad rausgefunden - nach der Fehlermeldung (mit einzelnen Anweisungen fortfahren) kompilliert er trotzdem und es funktioniert!

Ich glaub eher, das ganze basiert auf einem Bug!
Die Exe ist dann Problemlos ausfürbar!

Naja! Ich kreuz das hier mal als beantwortet an!

Also, für alle, die sich auch mit diesem Problem rumschlagen: Einfach nochmal F9 und alles ist gut!

Gruß
Seraph
Seraph Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 163

Windows.:siXPack:.
Delphi7 Professional
BeitragVerfasst: Mo 23.01.06 18:15 
Also ich muss hier leider doch nochmal schreiben!!!

Ich hab jetzt ein undefiniertes Array of TGroupBox, die wie folgt aufgerufen werden:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
procedure LoadContent();
var
 ObjectIndex: Integer;
 GroupBoxes: Array of TGroupBox;
begin
 ObjectIndex := -1;
 repeat
  ObjectIndex := ObjectIndex + 1;
  GroupBoxes[ObjectIndex] := TGroupBox.Create(MainForm.ContentBox); //TScrollBox
  GroupBoxes[ObjectIndex].Parent := MainForm.ContentBox;
  ...
 until ObjectIndex <> Globale Integer Variable;
end;


Sobald ich aus dem undefinierten Array ein definiertes mache (GroupBoxes: Array[0..30] of TGroupBox)
funktioniert das! Wenn nicht, gibts schon bei der ersten Zuweisung ...TGroupBox.Create(.... eine Zugriffsverletzung!!!!

Muss ich beim unsigned Array irgendwas anderes noch beachten oder hinzufügen???
Wäre cool wenn jamand weiter wüsste!

Danke im Voraus
Seraph
LLCoolDave
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 212

Win XP
Delphi 2005
BeitragVerfasst: Mo 23.01.06 18:18 
Ist ja auch kein Wunder, dein Array hat ja auch noch keine festgelegte Länge und somit den entsprechenden Speicher nicht zugewiesen gekriegt. Setlength() wirkt da Wunder.
Kroko
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1284

W98 W2k WXP
Turbo D
BeitragVerfasst: Mo 23.01.06 18:19 
man sollte einen dynamische Array auch Speicher zuweisen :!:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
procedure LoadContent();
var
 ObjectIndex: Integer;
 GroupBoxes: Array of TGroupBox;
begin
 ObjectIndex := -1;
 SetLength (GroupBoxes,1+Globale Integer Variable);
 repeat
  //ObjectIndex := ObjectIndex + 1;
  Inc (ObjectIndex); // besser

  GroupBoxes[ObjectIndex] := TGroupBox.Create(MainForm.ContentBox); //TScrollBox
  GroupBoxes[ObjectIndex].Parent := MainForm.ContentBox;
  ...
 until ObjectIndex <> Globale Integer Variable;
  // Freigabe mit Finalize (GroupBoxes);
end;


//EDIT zu lahm :cry:

_________________
Die F1-Taste steht nicht unter Naturschutz und darf somit regelmäßig und oft benutzt werden! oder Wer lesen kann, ist klar im Vorteil!
Seraph Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 163

Windows.:siXPack:.
Delphi7 Professional
BeitragVerfasst: Mo 23.01.06 18:34 
Bastel....Prog.....????....ah....hier..."und..aber..hmmm"

hmmm...Das war ja einfach!

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure bedanken();
var
 i: Integer;
 Abschlusstext: String;
begin
 Abschlusstext := '';
 for i := 0 to 999 do
  Abschlusstext := Abschlusstext + 'Danke';
end;



Abschlusstext


Gruß
Seraph
LLCoolDave
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 212

Win XP
Delphi 2005
BeitragVerfasst: Mo 23.01.06 18:52 
ausblenden Delphi-Quelltext
1:
Abschlusstext := DupeString('Danke ', 1000);					


;)