comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Whither Object
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Whither Object [message #34635] Wed, 09 April 2003 15:48 Go to previous message
MKatz843 is currently offline  MKatz843
Messages: 98
Registered: March 2002
Member
What is the best way to define a new object variable such that:
A) if the object class exists, then it is loaded.
B) if the object class is unknown then we return obj_new() or set a
failure flag somehow.

Given an object class name in a string, I'd like to make a flexible
definition:

a = obj_new("MyClass")

Then if there is a myclass__define.pro, we assign the object,
otherwise we assign obj_new().

Perhaps I could create a new object-definition function with a success
flag, like this

a = obj_new2("SchoolOnSaturday", noclass=noclass)
;-- noclass=1 if it failed.

To date, I've been using something like this

name = "MyClass"
CATCH, Error_Status

if (Error_status NE 0) then begin
print, 'Error_status = ', Error_Status
print, 'Error message: ', !ERROR_STATE.MSG
print, 'No such class'
endif else begin
a = obj_new(name)
endelse

That seems to work a little, but CATCH catches everything and I don't
like using it. Another idea is that we could have a new function
called obj_test() where

YesItExists = obj_test("MyClass")

Does such a function exist already? Has anyone out there solved this
for themselves?

Thanks,
M. Katz
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: LOCALE_GET()
Next Topic: Floating point error

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 10:56:59 PDT 2025

Total time taken to generate the page: 0.00459 seconds