unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
PData = ^TData;
TData =
record
Zahl: integer;
end;
TListe =
array of PData;
PListe = ^TListe;
PPListe = ^PListe;
TForm2 =
class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
Liste: PPListe;
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
//10 Einträge hinzufügen
procedure TForm2.Button1Click(Sender: TObject);
var
i: integer;
NewData: PData;
begin
for i := 1
to 10
do
begin
SetLength(Liste^^, Length(Liste^^) + 1);
New(NewData);
NewData^.Zahl := Length(Liste^^);
Liste^^[High(Liste^^)] := NewData;
end;
end;
//alle enthaltenen Werte ausgeben
procedure TForm2.Button2Click(Sender: TObject);
var
i: integer;
begin
for i := Low(Liste^^)
to High(Liste^^)
do
ShowMessage(IntToStr(Liste^^[i]^.Zahl));
end;
//Liste anlegen
procedure TForm2.FormCreate(Sender: TObject);
begin
New(Liste);
New(Liste^)
end;
//Aufräumen
procedure TForm2.FormDestroy(Sender: TObject);
var
i: integer;
begin
for i := Low(Liste^^)
to High(Liste^^)
do
Dispose(Liste^^[i]);
Dispose(Liste^);
end;
end.