Autor Beitrag
Adrian
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 314



BeitragVerfasst: Sa 16.08.03 18:45 
Servus!

Ich will zur Laufzeit im unteren Bildschirmteil 4 Zeilen mit je 7 Labels erstellen. Dazu verwende ich ein 2-dimensionales, dynamisches Array, so wie es in Peter Lustigs Tutorial erläutert wird. Leider meint mein Computer, daß ich da nicht alles richtig gemacht habe, denn beim Beenden meines Programms erhalte ich jedesmal die Fehlermeldung "Access violation at address... Write of Address..." Meine Vermutung geht dahin, daß die Behandlung des 2-dimensionalen dynamischen Arrays nicht sauber ist - wenn ich es auf 1-dimensional umstelle, funktioniert's - und möchte euch um Hilfe und Tipps fragen.

Dazu ein gekürzter Programmauszug:
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:
unit Messen;

var
  Form1: TForm1;
  Temperatur_Label: Array of Array of TLabel;

procedure TForm1.Timer1Timer(Sender: TObject);
var
  i,j: Integer;
begin
  SetLength(Temperatur_Label,8,5);
  for i:=1 to 4 do
  begin
    for j:=1 to 7 do
    begin
      Temperatur_Label[i,j]:=TLabel.Create(Form1);
      with Temperatur_Label[i,j] do
      begin
        Parent:=Form1;
        Left:=(j-1)*150+15;
        Top:=i*50+420;
        Font.Style:=[fsBold];
        Name:='Temperatur_Label'+IntToStr(i)+IntToStr(j);
        Caption:='Kanal '+IntToStr(i)+'.'+IntToStr(j);
      end;
    end;
  end;
Close;
end;

end.


Gruß,
Adrian

Moderiert von user profile iconTino: Delphi-Tags hinzugefügt.


Zuletzt bearbeitet von Adrian am Sa 16.08.03 19:29, insgesamt 1-mal bearbeitet
AndyB
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1173
Erhaltene Danke: 14


RAD Studio XE2
BeitragVerfasst: Sa 16.08.03 19:07 
Mit SetLength(Temperatur_Label,8,5); erzeugst du ein Array[0..7, 0..4]. Darauf greifst du in deinem Code aber so zu als handle es sich um ein Array[0..4, 0..7]. Vertausche einfach das i und das j, damit es passt.

Moderiert von user profile iconTino: Bold-Tags korrigiert.

_________________
Ist Zeit wirklich Geld?
Adrian Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 314



BeitragVerfasst: Sa 16.08.03 19:28 
Servus!

Danke für die schnelle Hilfe. Und da sitz' ich jetzt ein paar Stunden dran.

Gruß,

Adrian