![]() |
AW: Variable erhöhen, wie es in php möglich ist (varx++)?
Zitat:
Zitat:
Im Übrigen habe ich bemerkt, dass bei meinem Code immer eine Arraylänge zuviel dran ist. Wenn ich 10 erstelle, sind es 11. Warum ist das so? LG |
AW: Variable erhöhen, wie es in php möglich ist (varx++)?
Ich verstehe denn Zweck des ganzen Brimboriums nicht. Warum nicht einfach eine generische Liste:
Delphi-Quellcode:
Noch einfach geht es, wenn man statt des Arrays gleich ganz mit der Liste arbeitet.
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; |
AW: Variable erhöhen, wie es in php möglich ist (varx++)?
Und ich habe gedacht, ich bin der Einzige, der sich das fragt. :-D
|
AW: Variable erhöhen, wie es in php möglich ist (varx++)?
Hallo Uwe und Detlev,
ganz am Anfag meines Beitrags war die Frage eine gänzlich andere. Außerdem suchte ich nach einer Möglichkeit, ein Array ohne viele Umwege zu erstellen - und auch, ohne, dass ich mich um die Verwaltung dessen kümmern muss. Die Lösung von Dir, Uwe, ist dem, was ich nun gemacht habe wahrlich besser und auch strukturierter. Ich bin leider kein gelernter Programmierer, mir fallen solche Dinge nicht leicht. Jedoch macht es Spaß Lösungen zu Problemen zu finden, die sich ergeben. Danke an euch alle! LG |
Alle Zeitangaben in WEZ +1. Es ist jetzt 13:56 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz