I think ... the main advantage of Objects over say record structures is that
they are allocated on the heap and thus you can have as many of them as
memory available on the system. The other advantage is that objects have
their own methods. Therefore an object can be far more self-contained and
easier to maintain in a large program. With a simple structure and small
program you can probably get away comfortably with arrays of records ... as
things get more complicated you'll probably find it far easier, and your
code way more extendable if you use lists of objects.
-----Original Message-----
From: Ross Levis [mailto:[EMAIL PROTECTED]]
Sent: 6 July 2001 23:33
To: Multiple recipients of list delphi
Subject: Re: Listbox items (Was: Re: [DUG]: array of TStringList)
Thanks James, Ben & Reg. It's looks rather messy to me. I didn't realise
you
can create numerous duplicate objects with the same name. Is there any
advantage to using a Record object as opposed to a class(TObject)?
Ross.
James Low wrote:
> Thanks Ben ...
>
> -----Original Message-----
> From: Ben Taylor [mailto:[EMAIL PROTECTED]]
> Sent: 6 July 2001 17:01
> To: Multiple recipients of list delphi
> Subject: RE: Listbox items (Was: Re: [DUG]: array of TStringList)
>
> > AddObject('Somestring to display', myObject);
> > myObject.Free; //the list owns a reference to it now
>
> you _really_ dont want to do this.. the list now has a pointer to the
> object, but its still the same object. if you do the free, then the
> list holds an invalid pointer.
>
> > myObject := Listbox1.Objects[ListBox1.Listindex];
> this wont compile. you'll need to cast the TObject pointer to the
> correct type:
>
> myObject := tRossesObject(Listbox1.Objects[ListBox1.Listindex]);
>
> that should work better..
>
> there are 'nicer' OO ways to do this but it's friday and i'm going now
> :-)
>
> __________________________________________________
> Do You Yahoo!?
> Get personalized email addresses from Yahoo! Mail
> http://personal.mail.yahoo.com/
>
---------------------------------------------------------------------------
> New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
> Website: http://www.delphi.org.nz
> To UnSub, send email to: [EMAIL PROTECTED]
> with body of "unsubscribe delphi"
>
---------------------------------------------------------------------------
> New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
> Website: http://www.delphi.org.nz
> To UnSub, send email to: [EMAIL PROTECTED]
> with body of "unsubscribe delphi"
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED]
with body of "unsubscribe delphi"
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED]
with body of "unsubscribe delphi"