Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Cannot assign T... to T...
Hi out there,
Iīm getting crazy on a problem, hopefully someone can help me: I have
a decendant of TCollectionITem (TRessource) and a decendant of
TCollection (TRessources). I need a function which returns just some
items of the collection, depending on some field value of my
collectionitem. So I create my result and try to assign the values to
it, but I get "Cannot assign TRessource to TRessource". I know that I
need to override and implement my own assign method. But for this I
need to instantiate a new instance of TRessource. That is exactly what
I donīt want to do, I just want a list of references of the items that
match.
Maybe someone can help me? I appreciate any help on this, it already
took me too much time.
Thanks in advance!
Henning



TRessource = class(TCollectionItem)
private
FName:      String;
FFirstname: String;
public
property Name:      string read FName write FName;
property Firstname: string read FFirstname write FFirstname;
end;

TRessources = class(TCollection)
private
function    GetItems(Index: Integer): TRessource;
procedure   SetItems(Index: Integer; const value: TRessource);
public
constructor Create;
property    Items[Index: Integer]: TRessource read GetItems write
SetItems; default;
//procedure   Load; override;
end;

.....

function TScheduleItems.Ressources: TRessources;
var i: integer;
begin

result := TRessources.Create;

for i := 0 to Count - 1 do
begin
// some <if> stuff here...
if result.ItemByIDX(Schedule.ScheduleItems[i].Ressource.IDX) = nil
then
begin
result.Add;
result[result.Count - 1] :=
TRessource(Schedule.Ressources.ItemByIDX(Schedule.Ressources[i].IDX));
end;
end;
end;

Report this thread to moderator Post Follow-up to this message
Old Post
Henning
09-09-04 09:00 PM


Re: Cannot assign T... to T...
if you have the pro or better version of D then look at the
properties and source of how the TStringList is done..
most objects that use the Tstringlist name it as items
the set up the property as you have. with this you still
have methods that let you add, assign etc..
you can modify your assign to act as you want! have if
point to some external object of have it simply make a
duplication of it.
from what i can see i really think what you want it to
do is point to an external object and simply manipulate it.



Henning wrote:
> Hi out there,
> Iīm getting crazy on a problem, hopefully someone can help me: I have
> a decendant of TCollectionITem (TRessource) and a decendant of
> TCollection (TRessources). I need a function which returns just some
> items of the collection, depending on some field value of my
> collectionitem. So I create my result and try to assign the values to
> it, but I get "Cannot assign TRessource to TRessource". I know that I
> need to override and implement my own assign method. But for this I
> need to instantiate a new instance of TRessource. That is exactly what
> I donīt want to do, I just want a list of references of the items that
> match.
> Maybe someone can help me? I appreciate any help on this, it already
> took me too much time.
> Thanks in advance!
> Henning
>
>
>
>   TRessource = class(TCollectionItem)
>   private
>     FName:      String;
>     FFirstname: String;
>   public
>     property Name:      string read FName write FName;
>     property Firstname: string read FFirstname write FFirstname;
>   end;
>
>   TRessources = class(TCollection)
>   private
>     function    GetItems(Index: Integer): TRessource;
>     procedure   SetItems(Index: Integer; const value: TRessource);
>   public
>     constructor Create;
>     property    Items[Index: Integer]: TRessource read GetItems write
> SetItems; default;
>     //procedure   Load; override;
>   end;
>
> .....
>
> function TScheduleItems.Ressources: TRessources;
> var i: integer;
> begin
>
>   result := TRessources.Create;
>
>   for i := 0 to Count - 1 do
>   begin
>     // some <if> stuff here...
>     if result.ItemByIDX(Schedule.ScheduleItems[i].Ressource.IDX) = nil
> then
>     begin
>        result.Add;
>        result[result.Count - 1] :=
> TRessource(Schedule.Ressources.ItemByIDX(Schedule.Ressources[i].IDX));
>     end;
>   end;
> end;


Report this thread to moderator Post Follow-up to this message
Old Post
Jamie
09-10-04 09:01 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Delphi archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:02 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.