Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Die Delphi-IDE (https://www.delphipraxis.net/62-die-delphi-ide/)
-   -   Generic Component mit dynamischem Array geht nicht (https://www.delphipraxis.net/149105-generic-component-mit-dynamischem-array-geht-nicht.html)

Frizzi 14. Mär 2010 12:33


Generic Component mit dynamischem Array geht nicht
 
Eine generic Componente mit dynamischen Array compiliert zwar ohne Fehlermeldung, nur beim Testen gubt es einen Absturz.
Die Ursache ist ein fehlerhafter Wert für Length(Items), wenn Items ein dynamisches Array ist.
Falls jemand dazu eine Idee hat, so bitte um Mitteilung.

Lg Frizzi

Type
THFArrayBase<GItem> = class(
...
FArray :Array of GItem;

Type
THFByteArray = Class(THFArrayBase(Byte)
...

Procedure THFArrayBase<GItem>.Add(const Item:GItem);
Begin
SetLength(FArray,Length(FArray)+1);
FArray[High(FArray)] := Item;
If FSortDir <> sdNone then Sort;
End;

Procedure THFArrayBase.Add(const Items:Array of GItem);
Var
Inx,aLng,iLng :Integer;
Begin
aLng := Length(FArray);
iLng := Length(Items); //ergibt irgendeinen Fantasiewert
SetLength(FArray,aLng+iLng);
For Inx := 0 to High(Items) do
FArray[aLng+Inx] := Items[Inx];
If FSortDir <> sdNone then Sort;
End;


Alle Zeitangaben in WEZ +1. Es ist jetzt 06:14 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz