Einzelnen Beitrag anzeigen

Benutzerbild von sx2008
sx2008

Registriert seit: 15. Feb 2008
Ort: Baden-Württemberg
2.332 Beiträge
 
Delphi 2007 Professional
 
#5

Re: Bekomme einfach kein globales "Array of Record"

  Alt 28. Sep 2009, 22:25
Hier liegt ein besonderes Property vor; nämlich ein Array-Propery.
Delphi-Quellcode:
TProfil = record
    Name, Option1, Option2 : String;
    Wert: integer;
  end;

Profilspeicher = Array[1..30] of TProfil;

TSpeicher = class
  private
    FProfile: Profilspeicher;
    function GetProfile(Index: Integer): TProfil;
    procedure SetProfile(Index: Integer; P:TProfil);
  public
    property Profile[Index:Integer]: TProfil read GetProfile write SetProfile;
  end;

function TSpeicher.GetProfile(Index: Integer): TProfil;
begin
  if (Index >= Low(FProfile)) and (Index<=High(FProfile)) then
    Result := FProfile[index]
  else
    raise ERangeError.Create('ungültiger Index TSpeicher.Profile['+IntToStr(Index)+']');
end;
Am Besten du lässt zunächst die Methoden GetProfile und SetProfile weg und drückst dann STRG+C.
Delphi generiert dann automatisch dir richtigen Methodenrümpfe.
fork me on Github
  Mit Zitat antworten Zitat