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

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

by =?UTF-8?B?RGFubnkgU3Ryw7xtcGVs?= <dannys9@[EMAIL PROTECTED] > Apr 26, 2008 at 11:22 PM

alanglloyd@[EMAIL PROTECTED]
 schrieb:
> In a check function you set the Result to true, and then access a
> property or a method of a TMyClass instance. You absorb any exception
> in a try / except clause in which you set the Result to false.
> 
> Like ...
> 
> function TForm1.CheckMyClassInstantiated(Instance : TMyClass) :
> boolean;
> var
>   i : integer;
> begin
> {$O-}    // forces access to Item even though it is not used
>          // Delphi optimisation would otherwise not compile the access
> code
>   Result := true;
>   try
>     i := Instance.Item;
>   except
>     on Exception do
>       Result := false;  // if exception caused by no instance, then
> result is cleared
>   end;
> end;

No, please don't. That's a very ugly hack and completely unnecessary. 
Please read the other posts from Locke and me.

-- 
Gib mir eine Lederunterhose und ein Keyboard - man lebt nur einmal!

....und wech
          Danny <dannys9 (at) gmx (dot) de>
 




 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 Thu Aug 28 5:26:01 CDT 2008.