Einzelnen Beitrag anzeigen

Benutzerbild von Uwe Raabe
Uwe Raabe
Online

Registriert seit: 20. Jan 2006
Ort: Lübbecke
11.024 Beiträge
 
Delphi 12 Athens
 
#22

AW: Variable erhöhen, wie es in php möglich ist (varx++)?

  Alt 6. Mär 2022, 17:28
Ich verstehe denn Zweck des ganzen Brimboriums nicht. Warum nicht einfach eine generische Liste:
Delphi-Quellcode:
type
  TMyTippOfDayRecord = record
    Tipp: String;
    Info: String;
    constructor Create(const ATipp, AInfo: string);
  end;

Type
  TMyTippOfDay = TArray<TMyTippOfDayRecord>;

constructor TMyTippOfDayRecord.Create(const ATipp, AInfo: string);
begin
  Tipp := ATipp;
  Info := AInfo;
end;

function CreateTippOfDay: TMyTippOfDay;
var
  List = TList<TMyTippOfDayRecord>;
begin
  List := TList<TMyTippOfDayRecord>.Create;
  try
    List.Add(TMyTippOfDayRecord.Create('Bla 1', 'Hallo 1');
    List.Add(TMyTippOfDayRecord.Create('Bla 2', 'Hallo 2');
    List.Add(TMyTippOfDayRecord.Create('Bla 3', 'Hallo 3');
    List.Add(TMyTippOfDayRecord.Create('Bla 4', 'Hallo 4');
    Result := List.ToArray;
  finally
    List.Free;
  end;
end;
Noch einfach geht es, wenn man statt des Arrays gleich ganz mit der Liste arbeitet.
Uwe Raabe
Certified Delphi Master Developer
Embarcadero MVP
Blog: The Art of Delphi Programming
  Mit Zitat antworten Zitat