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 > Borland Delphi > Re: How To Chec...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 8 of 17 Topic 3709 of 3952
Post > Topic >>

Re: How To Check if an object is created (instantiated)?

by "Rudy Velthuis" <newsgroups@[EMAIL PROTECTED] > Apr 26, 2008 at 10:53 PM

Locke wrote:

> Delphi newbie speaking here so this could be wrong.
> 
> But I thought you could do something like:
> 
> if not Assigned(R) then
> begin
>   // Do stuff with R
> end;

A beginner's mistake, indeed. A variable is not necessarily set to nil
before it is used. If it is a local variable, it will be placed on the
stack, and the value it has (not that R is a pointer) is simply what
was there before the routine started.

Assigned can only check if something is nil, i.e. it can only check for
one defined value. Anything that is not nil can either be a valid
pointer or junk. No way to tell the difference, unless you use it and
it goes haywire (this is not necessarily the case!). Then you know it
wasn't valid. <g>

More here:

  http://rvelthuis.de/articles/articles-pointers.html#badpointers

-- 
Rudy Velthuis        http://rvelthuis.de

"It is better to have a permanent income than to be fascinating."
 -- Oscar Wilde (1854-1900)
 




 17 Posts in Topic:
How To Check if an object is created (instantiated)?
mohamad@[EMAIL PROTECTED]  2008-04-26 07:47:33 
Re: How To Check if an object is created (instantiated)?
Jim P <Jim_P@[EMAIL PR  2008-04-26 11:37:13 
Re: How To Check if an object is created (instantiated)?
Locke <jlocke@[EMAIL P  2008-04-26 20:47:02 
Re: How To Check if an object is created (instantiated)?
=?ISO-8859-1?Q?Danny_Str=  2008-04-26 23:00:50 
Re: How To Check if an object is created (instantiated)?
"Rudy Velthuis"  2008-04-26 23:05:30 
Re: How To Check if an object is created (instantiated)?
=?ISO-8859-1?Q?Danny_Str=  2008-04-27 13:46:55 
Re: How To Check if an object is created (instantiated)?
"Rudy Velthuis"  2008-04-27 20:46:03 
Re: How To Check if an object is created (instantiated)?
"Rudy Velthuis"  2008-04-26 22:53:00 
Re: How To Check if an object is created (instantiated)?
"alanglloyd@[EMAIL P  2008-04-26 14:05:39 
Re: How To Check if an object is created (instantiated)?
=?UTF-8?B?RGFubnkgU3Ryw7x  2008-04-26 23:22:04 
Re: How To Check if an object is created (instantiated)?
Jamie <jamie_ka1lpa_no  2008-04-26 18:56:13 
Re: How To Check if an object is created (instantiated)?
"Rudy Velthuis"  2008-04-26 23:11:32 
Re: How To Check if an object is created (instantiated)?
=?ISO-8859-1?Q?Danny_Str=  2008-04-26 23:17:02 
Re: How To Check if an object is created (instantiated)?
"Rudy Velthuis"  2008-04-26 23:00:22 
Re: How To Check if an object is created (instantiated)?
=?ISO-8859-1?Q?Danny_Str=  2008-04-27 13:31:09 
Re: How To Check if an object is created (instantiated)?
"Rudy Velthuis"  2008-04-27 20:48:58 
Re: How To Check if an object is created (instantiated)?
"Rudy Velthuis"  2008-04-26 22:46:30 

Post A Reply:
  Go here to Signup

AddThis Feed Button


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

Contact
tan12V112 Mon Oct 13 4:33:06 CDT 2008.