Autor Beitrag
darkdester
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 100



BeitragVerfasst: Di 19.05.09 14:32 
also ich mach bestimmt einen ganz dummen denkfehler...

dyn. integer array

und dann wollte ich einfach

z.B. p:=dynArr[10];

p ist auch integer


aber ich bekomm ne access violation :|

woran liegts?

danke für die hilfe
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8548
Erhaltene Danke: 477

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Di 19.05.09 14:35 
Wie groß ist das Array? Hast du vorher mit Setlength die Länge entsprechend hoch gesetzt? Um auf dynArr[10] zugreifen zu können, muss es mindestens die Länge 11 haben.

_________________
We are, we were and will not be.
darkdester Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 100



BeitragVerfasst: Di 19.05.09 14:40 
hab vorher setlength standardmäßig 15

wird aber immer größer

aber egal welchen wert ich nehme hab immer access violation :/
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8548
Erhaltene Danke: 477

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Di 19.05.09 14:43 
Hm, dann zeig mal etwas mehr Code. Kommst du evtl. mit globalen und lokalen Variablen durcheinander? :nixweiss:

_________________
We are, we were and will not be.
darkdester Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 100



BeitragVerfasst: Di 19.05.09 14:47 
hmm also p wäre jetzt ne globale
das array ist aber lokal

liegts daran? aber im prinzip könnts dem doch egal sein..ich fütter ihn ja nur einmal

also es sieht ganz einfach aus:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
//global

var
p:integer;

und
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
procedure TForm1.Button1Click(Sender: TObject);
var
dynArr :Array of Integer;

SetLength(dynArr,15);
....

und dann einfach
ausblenden Delphi-Quelltext
1:
p:=dynArr[10]; whatever					


Moderiert von user profile iconGausi: Delphi-Tags hinzugefügt
ffgorcky
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 573

WIN XP/2000 & 7Prof (Familie:Win95,Win98)

BeitragVerfasst: Di 19.05.09 14:59 
Also ich würde vorher noch sowas fragen:
ausblenden Delphi-Quelltext
1:
if not array[angesprochenerIndex]=nil then					

Ich meine zumindest, wenn der Platz noch keinen Wert zugewiesen bekommen hat, dann könnte das doch sein.
- Oder irre ich da jetzt?


Zuletzt bearbeitet von ffgorcky am Di 19.05.09 15:00, insgesamt 1-mal bearbeitet
Nersgatt
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1581
Erhaltene Danke: 279


Delphi 10 Seattle Prof.
BeitragVerfasst: Di 19.05.09 14:59 
Nur mal testweise: Deklarier mal eine lokale Integer-Variable und weise dieser den Arraywert zu. Tritt das selbe Problem auf?

_________________
Gruß, Jens
Zuerst ignorieren sie dich, dann lachen sie über dich, dann bekämpfen sie dich und dann gewinnst du. (Mahatma Gandhi)
darkdester Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 100



BeitragVerfasst: Di 19.05.09 15:44 
spinnt das forum heute?! vorhin database error etc..

also b2t

wenn ich das aarray global nehme selber fehler

wenn ich die variable lokal nehme dann GEHTS!

ABER wenn ich dann den wert der var auf eine globale var überschreiben will, sprich p:=g, wobei p global und g lokal, dann kommt wieder violation o_O