Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Delphi > Re: Has a TStri...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 10 of 13 Topic 1081 of 1135
Post > Topic >>

Re: Has a TStringlist been created

by Nicholas Sherlock <N.sherlock@[EMAIL PROTECTED] > Oct 15, 2006 at 12:16 PM

J French wrote:
> On Sat, 14 Oct 2006 07:20:43 +1300, Nicholas Sherlock
> <N.sherlock@[EMAIL PROTECTED]
> wrote:
> 
>> J French wrote:
>>> Well, I used to use the:   If Assigned( SomeObj ) Then   approach
>>> - but I found that I was having to make darn sure that I was doing
>>> SomeObj := Nil   at the begining of the routine because local
>>> variables are not cleared when put on the Stack (except when they are
>>> <g> )
> 
>> But doesn't this just translate to being darn sure that you set your 
>> flag correctly? What is the advantage?
> 
> Well the Flag is quite oviously a Flag, while the 4 byte Object
> pointer is a potential Object - but it is also being used as a Flag

I still don't see the advantage. I do something like this:

var myobj:TObject;

Initialization:

myobj:=nil;

some time later..

myobj:=TObject.create;

some time later..

If assigned(myobj) then use it, otherwise don't.

still later...

FreeAndNil(myobj);

You are recommending something like this:

var
  myobj:TObject;
  objvalid:boolean;

Initialization:

objvalid:=false;

some time later..

myobj:=TObject.create;
objvalid:=true;

some time later..

If objvalid then use it, otherwise don't.

still later...

myobj.free;
objvalid:=false;

What is the advantage?

Cheers,
Nicholas Sherlock

-- 
http://www.sherlocksoftware.org
 




 13 Posts in Topic:
Has a TStringlist been created
Rich <taxidermist@[EMA  2006-10-12 21:36:53 
Re: Has a TStringlist been created
Rob Kennedy <me3@[EMAI  2006-10-13 01:11:39 
Re: Has a TStringlist been created
erewhon@[EMAIL PROTECTED]  2006-10-13 06:58:58 
Re: Has a TStringlist been created
Nicholas Sherlock <N.s  2006-10-13 19:58:22 
Re: Has a TStringlist been created
erewhon@[EMAIL PROTECTED]  2006-10-13 08:09:50 
Re: Has a TStringlist been created
Jamie <jamie_ka1lpa_no  2006-10-13 14:08:16 
Re: Has a TStringlist been created
erewhon@[EMAIL PROTECTED]  2006-10-14 08:08:16 
Re: Has a TStringlist been created
Nicholas Sherlock <N.s  2006-10-14 07:20:43 
Re: Has a TStringlist been created
erewhon@[EMAIL PROTECTED]  2006-10-14 08:12:43 
Re: Has a TStringlist been created
Nicholas Sherlock <N.s  2006-10-15 12:16:54 
Re: Has a TStringlist been created
erewhon@[EMAIL PROTECTED]  2006-10-15 08:18:27 
Re: Has a TStringlist been created
Jamie <jamie_ka1lpa_no  2006-10-13 14:00:11 
Re: Has a TStringlist been created
Jamie <jamie_ka1lpa_no  2006-10-28 23:23:17 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Oct 11 15:27:33 CDT 2008.