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

Home » Public Forums » archive » Re: keyword_set() NullObject and NullPointer
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: keyword_set() NullObject and NullPointer [message #15044] Fri, 16 April 1999 00:00
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Luis (euluis@netscape.net) writes:

> IDL version 5.1.1, Windows
> in the online documentation of keyword_set() isn't refered
> what is the behavior with Null object and Null Pointer.
>
> I've tryed and it returns 0, which is good for me, because
> that is the behavior that fits my needs. Because I'm developing
> an complex program and that behavior isn't documented, I'm
> afraid that it could change. Is that possible? Someone from RDI
> told you something?

No one from RDI told be nuttin', but I would be very
careful if I were you. Something in the tone of your
question leads me to think there is a VERY strong
possibility that you are using Keyword_Set for the
wrong reason.

Keyword_Set should ONLY be used with keywords that
have a binary-type functionality. They are on or off,
true or false, yes or no, 0 or 1. Using Keyword_Set
for any other purpose will get you into trouble sooner
or later.

Having said that, Keyword_Set doesn't behave with pointers
exactly the way I would hope it would. The documentation
says that Keyword_Set returns a 0 if the augment is 0
or undefined. If the argument is anything else at all,
it returns a 1. (Notice it says NOTHING whatsoever about
whether the keyword is *used* or not. Nor can it tell you
this information. And if you thought it did, you would
be mistaken.)

What it does tell you about pointers (and the more I
think about it the more I am sure there is NEVER a
reason to be using Keyword_Set with pointers) is whether
you have a valid pointer or not:

a = Ptr_New() ; Null and invalid pointer.
Print, Keyword_Set(a)
0

b = Ptr_New(5) ; Valid pointer.
Print, Keyword_Set(b)
1

c = Ptr_New(/Allocate_Heap) ; Valid pointer to undefined variable.
Print, Keyword_Set(c)
1

Perhaps that is the information you wanted from Keyword_Set, but
if it is, a much safer way to get it would be to use Ptr_Valid().

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: call IDL from Tcl/Tk
Next Topic: keyword_set() NullObject and NullPointer

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

Current Time: Wed Oct 08 19:12:57 PDT 2025

Total time taken to generate the page: 0.00541 seconds