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 17 of 17 Topic 3709 of 3900
Post > Topic >>

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

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

mohamad@[EMAIL PROTECTED]
 wrote:

> I have this simple code that I could find an answer to yet without
> trigiring an exceptiom.
> 
> 
> Type
>   TMyClass = Class (tobject);
>      Item : integer;
>   end;
> 
> 
> procedure Somename(Var R : TMyClass);
> begin
> ...
>   Now, inside a program how can I check to see if the Variable R has
> an instance?

You can't. If R is not initialized, and a local variable, it can have
any value, and there is no viable way to find out if that value is a
random value pointing to a random spot in memory or a valid value that
points to a valid instance.

Now, if your code is designed properly, you'll never have to ask this
question. If you are just the author of the procedure, and have no idea
who will call your procedure, the responsibility is on the user to make
sure that a valid instance is passed.

-- 
Rudy Velthuis        http://rvelthuis.de

"The power of accurate observation is frequently called cynicism 
 by those who don't have it."
 -- George Bernard Shaw (1856-1950)
 




 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 Sat Sep 6 22:25:54 CDT 2008.