Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check if an Object Exists (is available)

Status
Not open for further replies.

tschonken

Programmer
Jul 3, 2002
21
ZA
This might seem like an odd question, but maybe my explanation will clear it up.

Is there any way of checking if an Object is available to use?

The scenario is this:
I want to use a class ie. set myVal = new MyClass
I want to know if the class "MyClass" is included in this ASP page.
We are using a lot of include files (that include other files and are included by other) and in some cases this page is included in pages where the "MyClass" have already been included and in other cases not. How do I know if it has been included or not?

 
if isObject(myClass) then.... -- Just trying to help...
[wolf]<--- This is a wolf? We need a new icon.......
mikewolf@tst-us.com
 
Well Mike, I'm not sure your code will work because in order for it to work, You must pass an object variable (not a class name) to isObject function. What can be done :
Code:
on error resume next 'begins error handling
set toto = new myClass
if err.number > 0 then
  msgbox &quot;myClass object not found.&quot;
  err.clear 
end if
on error goto 0 'stops error handling
Water is not bad as long as it stays out human body ;-)
 
Oops, good catch targol!

If you wanted to use my code, you could create a bogus variable on the include page where you create the class and then check for it using isObject() on this page. If the variable is an object, then the class definition is also available on the page....




-- Just trying to help...
[wolf]<--- This is a wolf? We need a new icon.......
mikewolf@tst-us.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top