Einzelnen Beitrag anzeigen

NeoXan
(Gast)

n/a Beiträge
 
#1

Pointer mit einer Stringlist

  Alt 6. Okt 2004, 17:29
Delphi-Quellcode:
type
 TAttack = record
  Name : String;
  Description : TStringlist;
 end;
 ArAttack = Array[1..10] of TAttack;

type
 TTechnique = record
  Name : String;
  Attack : ArAttack;
 end;
 pTechnique = ^TTechnique;

var
 TheList : TList;

[...]

procedure TfrmMain.AddToList(Str: String; Ar: ArAttack);
var p: pTechnique;
    i: integer;
begin
 new(p);
 p^.Name := Str;
 AddResults('0',Str,true);

 for i:=1 to Length(Ar) do
 begin
  if Ar[i].Name <> 'then
   begin
    p^.Attack[i].Name := Ar[i].Name;
    p^.Attack[i].Description := Ar[i].Description;
    TheList.Add(p);
   end;
 end;
end;

procedure TfrmMain.FormCreate(Sender: TObject);
var tmpAr: ArAttack;
    tmpStrings: TStringlist;
begin
 TheList := TList.Create;
 tmpStrings := TStringlist.Create;

 tmpAr[1].Name := 'At1';
 tmpStrings.Add('This is the text for At1');
 tmpAr[1].Description := tmpStrings;
 tmpStrings.Clear;

 tmpAr[2].Name := 'At2';
 tmpStrings.Add('This is the text for At2');
 tmpAr[2].Description := tmpStrings;
 tmpStrings.Clear;

 AddToList('Tech',tmpAr);
[...]
end;
und wenn ich nun das hier versuche

Delphi-Quellcode:
  p := TheList[0];

  ShowMessage(p^.Name);
  ShowMessage(p^.Attack[1].Name);

  memDesc.Assign( p^.Attack[1].Description ); //<======
klappt alles bis auf die Letzte Zeile ?!
  Mit Zitat antworten Zitat