Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi typisierte Objektliste funktioniert nicht (https://www.delphipraxis.net/76090-typisierte-objektliste-funktioniert-nicht.html)

DGL-luke 29. Aug 2006 19:16


typisierte Objektliste funktioniert nicht
 
Hallo,

die hier: http://www.delphipraxis.net/internal...light=template beschriebenen templates funktionieren bei mir (Delphi 2006) nicht.
Der Compiler bemängelt, dass TObjectList nicht definiert sei...

Hier meine Implementation:

Delphi-Quellcode:
unit UCollectionList;

interface

uses dpCollection;

type
 _TObjectListItem = TJsCollection;
    {$I typedlisttemplate.pas}
  TCollectionList = class(_TObjectList)
  end;

implementation

  {$I typedlisttemplate.pas}

end.
Delphi-Quellcode:
...
{$IFNDEF _SECOND_PASS}
type

  _TObjectlist = class
  private
  protected
    fList: TObjectList; //hier "Knallts"
    function GetItems(_Idx: integer): _TObjectListItem;
    function GetCount: integer;
  public
    constructor Create;
    destructor Destroy; override;
    function Add(_Item: _TObjectListItem): integer;
    function Remove(_Item: _TObjectListItem): integer;
    procedure Clear;
    property Items[_Idx: integer]: _TObjectListItem read GetItems; default;
    property Count: integer read GetCount;
  end;
{$DEFINE _DECLARE_SECOND_PASS}
...

alcaeus 29. Aug 2006 19:28

Re: typisierte Objektliste funktioniert nicht
 
Fuege mal die unit Contnrs (ausser sie heisst anders, auf alle Faelle die Unit, in der die Klasse definiert ist) oben bei der DP-Collection zur uses-Liste hinzu ;)

Greetz
alcaeus

DGL-luke 29. Aug 2006 19:39

Re: typisierte Objektliste funktioniert nicht
 
ähm...

[Pascal Fehler] typedlisttemplate.pas(25): E2029 'UNIT' erwartet, aber 'TYPE' gefunden

Delphi-Quellcode:
...
{$IFDEF _DECLARE_SECOND_PASS}
   {$DEFINE _SECOND_PASS}
   {$UNDEF _DECLARE_SECOND_PASS}
{$ENDIF _DECLARE_SECOND_PASS}

{$IFNDEF _SECOND_PASS}
type                      //<--- HIER

  _TObjectlist = class
  private
...

Daniel G 29. Aug 2006 19:41

Re: typisierte Objektliste funktioniert nicht
 
Zitat:

Zitat von DGL-luke
ähm...

[Pascal Fehler]E2029 'UNIT' erwartet, aber 'TYPE' gefunden

Na', was sagt uns die Fehlermeldung jetzt? :mrgreen:

DGL-luke 29. Aug 2006 19:45

Re: typisierte Objektliste funktioniert nicht
 
:wall:

Nein, ich werd in dieses hockomplexe Gebilde jetzt NICHT einfach "unit unit1;" reinschreiben...

alcaeus 29. Aug 2006 19:46

Re: typisierte Objektliste funktioniert nicht
 
*hust* Du haettest dich ans Beispiel halten sollen. So sollte der Code passen:

Delphi-Quellcode:
unit UCollectionList;

interface

uses dpCollection, Contnrs;

type
  _LIST_ITEM_ = TJsCollection;
  {$DEFINE TYPED_LIST_TEMPLATE}
  {$I typedlisttemplate.pas}
  TCollectionList = _LIST_;

implementation

{$I typedlisttemplate.pas}

end.
Man beachte die Zeile mit der Definition von TYPED_LIST_TEMPLATE ;)

Greetz
alcaeus

DGL-luke 29. Aug 2006 19:49

Re: typisierte Objektliste funktioniert nicht
 
alcaeus hat mir jetzt geholfen...

mit dem "original"-template hab ichs hingekriegt.


Alle Zeitangaben in WEZ +1. Es ist jetzt 10:09 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