Autor Beitrag
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Mi 31.05.06 18:55 
Hallo,

hier tritt bei mir ein Fehler auf:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
type
TComboArray = array of array[0..5] of TCombobox;

private
FEingabeArray : TComboArray;

SetLength(FEingabeArray,2);

Dort bekomm ich immer eine Zugriffsverletzung und weiß nicht warum?!?
Hat das was damit zu tun, dass FEingabeArray als private deklariert ist?

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot


Zuletzt bearbeitet von Marco D. am Mi 31.05.06 19:03, insgesamt 1-mal bearbeitet
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 31.05.06 19:03 
Folgender Code mit Deiner Deklaration arbeitet bei mir problemlos:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
procedure TForm1.FormCreate(Sender: TObject);
begin
  SetLength(FEingabeArray,2);
  FEingabeArray[0][0] := TComboBox.Create(self);
  FEingabeArray[0][0].Parent := self;
end;


Bei mir gehört das Array zur Form, falls bei Dir nicht: Hast Du auch das Objekt erstellt, zu dem Dein Array gehört?

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
Marco D. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Mi 31.05.06 19:12 
Nochmal neu:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
var
  Form1: TForm1;
  blubb:TMarkFile;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
blubb:=TMarkFile.create('test','test');
end;

Ich habe blubb ordnungsgemäß erzeugt.

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Marco D. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Do 01.06.06 16:04 
Ich habe das Projekt mal hochgeladen in der Hoffnung, dass mir jemand sagen kann, was der Fehler ist. Bedenkt die Datei maf.pas Dort befindet sich die Methode TMarkFile.DeleteSubject (Sender : TObject). Am Ende dieser Prozedur tritt der Fehler auf. Um diesen auszulösen, muss man auf Button1 und dann auf einen der drei Buttons mit dem X klicken.

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot


Zuletzt bearbeitet von Marco D. am Fr 02.06.06 16:27, insgesamt 1-mal bearbeitet
Marco D. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Fr 02.06.06 08:54 
Kann mir denn niemand helfen? Komisch ist, dass in der Procedure AddSubjects beim Befehl SetLength keine Zugriffsverletzung auftritt.

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Fr 02.06.06 09:08 
Hallo!

(1) Wenn Du ein Array hast, welches Du explizit mit Array[0..5] of TComboBox deklarierst, wieso greifst Du dann auf die Indizes 1 bis 6 zu? Klar, dass das krachen muss. ;-)

(2) In der Prozedur DeleteSubject hast Du wohl am Ende was vergessen.
ausblenden Delphi-Quelltext
1:
2:
  SetLength(FEingabeArray,Length(FEingabeArray)-1);
  SetLength(BtnLoeschenArray,Length(BtnLoeschenArray)-1);


Grüße
Christian

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
Marco D. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Fr 02.06.06 14:51 
Das löst das Problem leider auch nicht.

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Fr 02.06.06 15:13 
Bei mir hat es das Problem gelöst.

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
Marco D. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Fr 02.06.06 15:15 
user profile iconChristian S. hat folgendes geschrieben:
Bei mir hat es das Problem gelöst.

Kannst du das Projekt bitte mal hochladen?!?

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Fr 02.06.06 15:22 
Hab ich schon wieder gelöscht. Du musst einfach nur schauen, dass Deine Schleifen von 0 bis 5 und nicht von 1 bis 6 laufen und das SetLength anpassen.

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
Marco D. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Fr 02.06.06 15:28 
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
//ENTFERNT SUBJECTS
procedure TMarkFile.DeleteSubject(Sender : TObject);
var row,i,i2:integer;
begin
  row:=(Sender as TButton).Tag;
  if row=High(FEingabeArray) then
  begin
    for i2 := 0 to 5 do
    begin
      FEingabeArray[row][i2].Free;
    end;
    BtnLoeschenArray[row].Free;
  end else
  begin
    for i := row to High(FEingabeArray)-1 do
    begin
      for i2 := 0 to 5 do
      begin
        FEingabeArray[i][i2].text:=FEingabeArray[i+1][i2].text;
      end;
      BtnLoeschenArray[i].Tag:=BtnLoeschenArray[i+1].Tag;
    end;
      for i2 := 0 to 5 do
      begin
      FEingabeArray[High(FEingabeArray)][i2].Free;
      end;
      BtnLoeschenArray[High(BtnLoeschenArray)].Free;
  end;
  SetLength(FEingabeArray,Length(FEingabeArray)-1);
  SetLength(BtnLoeschenArray,Length(BtnLoeschenArray)-1);
  UpdateSubjects;
end;

So funzt es nicht.

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Fr 02.06.06 15:32 
:roll: Ich dachte, es wäre eine zumutbare Eigenleistung, auf die Idee zu kommen, auch in anderen Prozeduren die Schleifenvariablen anzupassen.

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
Marco D. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Fr 02.06.06 15:49 
user profile iconChristian S. hat folgendes geschrieben:
:roll: Ich dachte, es wäre eine zumutbare Eigenleistung, auf die Idee zu kommen, auch in anderen Prozeduren die Schleifenvariablen anzupassen.

Ja ist es ja auch :-) Mach ich sofort

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Marco D. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Fr 02.06.06 15:51 
Klasse, es funktioniert :zustimm: Danke für deine Hilfe!!!

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Fr 02.06.06 16:12 
Prima :-) Entschuldige meinen ruppigen Ton.

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
Marco D. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Fr 02.06.06 16:15 
user profile iconChristian S. hat folgendes geschrieben:
Prima :-) Entschuldige meinen ruppigen Ton.

Macht ja nichts. Ich hatte wirklich in den anderen auch schon nachgeguckt, aber die for-Schleife bei AddSubjects vergessen. :autsch:

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot