Method_valid [message #40507] |
Mon, 16 August 2004 11:21  |
Andrew Meigs
Messages: 8 Registered: November 2000
|
Junior Member |
|
|
Is there a way efficiently check if an object has a method? I vaguely
remember this topic coming up in the newsgroup before but my googling has
not been fruitful.
I can of course use the following code to check the existence of a 'copy'
method (a general function is not hard at all as well):
FUNCTION copyCheck, objToCheck
Catch, theError
IF theError NE 0 THEN BEGIN
Catch, /Cancel
RETURN, 0
ENDIF
c = objToCheck -> copy() ;; if ok then goes to next line, if not then
goes to the catch error code
obj_destroy, c ;; don't really want to copy if it's valid. -- 16-08-2004
AGM -- may be inefficient for large objects (surely there's an
method_valid???)
return, 1
END
However, as my code comments suggest if the method actually executes then
there could be large overhead.
Thanks,
Andy
|
|
|
Re: Method_valid [message #40580 is a reply to message #40507] |
Wed, 18 August 2004 06:41  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Ben Tupper writes:
> He's one of the the cutting edge wizzes
> standing upside down in the southern hemisphere; one of those guys who can do
> anything and do it well.
And not only that, until very, very recently he did all
his machinations on VAX computers! A real throwback to
the glory days of computing! :-)
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|
Re: Method_valid [message #40581 is a reply to message #40507] |
Wed, 18 August 2004 06:26  |
btt
Messages: 345 Registered: December 2000
|
Senior Member |
|
|
Andy Meigs wrote:
> Ben, who's "Andrew Cool" ?
>
Sounds like a made-up name doesn't it. He's one of the the cutting edge wizzes
standing upside down in the southern hemisphere; one of those guys who can do
anything and do it well. Search for Andrew's name in the newsgroup using
Googles search engine. You'll get the idea.
|
|
|
Re: Method_valid [message #40582 is a reply to message #40507] |
Wed, 18 August 2004 05:56  |
Andrew Meigs
Messages: 8 Registered: November 2000
|
Junior Member |
|
|
Ben, who's "Andrew Cool" ?
Andy
"Andy Meigs" <ameigs@jet.uk> wrote in message
news:cfv6ne$ldb$1@codas.jet.uk...
> Thanks guys-- will try out Jim Pendleton's routines.
>
> Andy
>
> "David Fanning" <davidf@dfanning.com> wrote in message
> news:MPG.1b8bb5c48df039f5989837@news.frii.com...
>> David Fanning writes:
>>
>>>> I am loathe to contradict you David, especially since I am still
>>>> hyperventilating because Andrew Cool's has used objects - but there
> are two
>>>> functions available at the RSI user contribution site written, by
Jim
> Pendelton,
>>>> called Object_HasMethod and Class_HasMethod. I think that is what
> Andy wants.
>>
>> Son-of-a-gun! I already had these files on my computer.
>> *Now* do you see why I write articles for my web page! :-)
>>
>> Cheers,
>>
>> David
>> --
>> David Fanning, Ph.D.
>> Fanning Software Consulting, Inc.
>> Coyote's Guide to IDL Programming: http://www.dfanning.com/
>
>
|
|
|
Re: Method_valid [message #40584 is a reply to message #40507] |
Wed, 18 August 2004 02:15  |
Andrew Meigs
Messages: 8 Registered: November 2000
|
Junior Member |
|
|
Thanks guys-- will try out Jim Pendleton's routines.
Andy
"David Fanning" <davidf@dfanning.com> wrote in message
news:MPG.1b8bb5c48df039f5989837@news.frii.com...
> David Fanning writes:
>
>>> I am loathe to contradict you David, especially since I am still
>>> hyperventilating because Andrew Cool's has used objects - but there
are two
>>> functions available at the RSI user contribution site written, by Jim
Pendelton,
>>> called Object_HasMethod and Class_HasMethod. I think that is what
Andy wants.
>
> Son-of-a-gun! I already had these files on my computer.
> *Now* do you see why I write articles for my web page! :-)
>
> Cheers,
>
> David
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|
Re: Method_valid [message #40594 is a reply to message #40507] |
Tue, 17 August 2004 06:27  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
David Fanning writes:
>> I am loathe to contradict you David, especially since I am still
>> hyperventilating because Andrew Cool's has used objects - but there are two
>> functions available at the RSI user contribution site written, by Jim Pendelton,
>> called Object_HasMethod and Class_HasMethod. I think that is what Andy wants.
Son-of-a-gun! I already had these files on my computer.
*Now* do you see why I write articles for my web page! :-)
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|
Re: Method_valid [message #40595 is a reply to message #40507] |
Tue, 17 August 2004 06:23  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Ben Tupper writes:
> I am loathe to contradict you David, especially since I am still
> hyperventilating because Andrew Cool's has used objects - but there are two
> functions available at the RSI user contribution site written, by Jim Pendelton,
> called Object_HasMethod and Class_HasMethod. I think that is what Andy wants.
Well, there you go! Thank goodness Jim has the patience
to parse the ROUTINE_INFO information. Just be sure you
have compiled the sucker first and haven't just restored
the object. :-)
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|
Re: Method_valid [message #40597 is a reply to message #40507] |
Tue, 17 August 2004 05:41  |
btt
Messages: 345 Registered: December 2000
|
Senior Member |
|
|
David Fanning wrote:
> Andy Meigs writes:
>
>
>> Is there a way efficiently check if an object has a method? I vaguely
>> remember this topic coming up in the newsgroup before but my googling has
>> not been fruitful.
>
>
> I don't remember the thread, but I think the answer
> is still "No, there is no way to check if an object
> has a method", except to try it and fail, as you
> suggest.
>
Hi,
I am loathe to contradict you David, especially since I am still
hyperventilating because Andrew Cool's has used objects - but there are two
functions available at the RSI user contribution site written, by Jim Pendelton,
called Object_HasMethod and Class_HasMethod. I think that is what Andy wants.
Ben
|
|
|
Re: Method_valid [message #40600 is a reply to message #40507] |
Mon, 16 August 2004 21:35  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Andy Meigs writes:
> Is there a way efficiently check if an object has a method? I vaguely
> remember this topic coming up in the newsgroup before but my googling has
> not been fruitful.
I don't remember the thread, but I think the answer
is still "No, there is no way to check if an object
has a method", except to try it and fail, as you
suggest.
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|