unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
PGegnerRecord = ^TGegnerRecord;
TGegnerRecord =
record
Name:AnsiString;
PosX:Integer;
PosY:Integer;
{...}
end;
TForm1 =
class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure FormClose(Sender: TObject;
var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
Gegnerliste:TList;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
Gegnerliste:=TList.Create;
end;
procedure TForm1.FormClose(Sender: TObject;
var Action: TCloseAction);
Var i:Integer;
Begin
For i:=Gegnerliste.Count-1
downto 0
do //Löschen von Einträgen
Dispose(PGegnerRecord(Gegnerliste.Items[i]));
//Speicher wieder freigeben!
Gegnerliste.Free;
end;
procedure TForm1.Button1Click(Sender: TObject);
Var GegnerRec:PGegnerRecord;
index:Integer;
begin
New(GegnerRec);
//Speicher reservieren
Gegnerliste.Add(GegnerRec);
index:=Gegnerliste.Count;
GegnerRec.
Name:='
Gegner'+IntToStr(
index);
GegnerRec.PosX:=index;
GegnerRec.PosY:=30;
end;
procedure TForm1.Button2Click(Sender: TObject);
Var i:Integer;
begin
For i:=0
to Gegnerliste.Count-1
do
ShowMessage(TGegnerRecord(Gegnerliste[i]^).
Name);
end;