It's still not an object. Records are traditional procedural structures.
They don't have anything OO about them.
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
> Behalf Of NIRAV KAKU
> Sent: Saturday, 7 July 2001 06:19
> To: Multiple recipients of list delphi
> Subject: Re: Listbox items (Was: Re: [DUG]: array of TStringList)
>
>
> Heres some really quick & dirty code to throw some light on the
> subject:
>
> << Records as objects >>
>
> TMyRec = record
> Name: String;
> Age: Integer;
> end;
> pTMyRec = ^TMyRec;
>
> procedure TForm1.Button1Click(Sender: TObject);
> var
> MyObj: TObject;
> MyRec: TMyRec;
> PMyRec: pTMyRec;
>
> Z: pTMyRec;
> begin
> MyRec.Name := 'NIRAV KAKU';
> MyRec.Age := 22;
>
> // record to object
> PMyRec := @MyRec;
> MyObj := TObject(PMyRec);
>
> // object to record
> Z := pTMyRec(MyObj);
>
> // testing results
> ShowMessage(TMyRec(Z^).Name);
> ShowMessage(IntToStr(TMyRec(Z^).Age));
> end;
>
> Records save memory.
>
> Hope this helped.
>
> regards,
> NIRAV KAKU
>
>
> On 6 Jul 01, at 23:33, Ross Levis wrote:
>
> > 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"
> >
> >
>
>
>
> - From the Shreemat Bhägwat Gïta -
> 'Sarcasm is the lowest form of wit.'
> ------------------------------------------------------------------
> ---------
> 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"