Einzelnen Beitrag anzeigen

Benutzerbild von himitsu
himitsu

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
43.203 Beiträge
 
Delphi 12 Athens
 
#6

AW: Feldwerte eines Records über den Feldindex abrufen

  Alt 11. Sep 2023, 16:22
oder manuell

Delphi-Quellcode:
type
  TMyRecord = packed record
  private
    function GetFeld(idx: Integer): string;
    procedure SetFeld(idx: Integer; const Value: string);
  public
    FeldA, FeldB, FeldC: string;
    property Feld[idx: Integer]: string read GetFeld write SetFeld;
  end;

  // oder

  TMyRecord = packed record
  private
    FFeld: array[0..2] of string;
    function GetFeld(idx: Integer): string;
    procedure SetFeld(idx: Integer; const Value: string);
  public
    property FeldA: string index 0 read GetFeld write SetFeld;
    property FeldB: string index 1 read GetFeld write SetFeld;
    property FeldC: string index 2 read GetFeld write SetFeld;
    property Feld[idx: Integer]: string read GetFeld write SetFeld;
  end;

  // oder (wobei, neeeeeee)

  TMyRecord = packed record
  private
    function GetFeld(idx: Integer): string;
    procedure SetFeld(idx: Integer; const Value: string);
  public
    Feld: array[0..2] of string;
    property FeldA: string index 0 read GetFeld write SetFeld;
    property FeldB: string index 1 read GetFeld write SetFeld;
    property FeldC: string index 2 read GetFeld write SetFeld;
  end;

  // oder ....
Garbage Collector ... Delphianer erzeugen keinen Müll, also brauchen sie auch keinen Müllsucher.
my Delphi wish list : BugReports/FeatureRequests

Geändert von himitsu (11. Sep 2023 um 16:26 Uhr)
  Mit Zitat antworten Zitat