[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: keyword_set bug or feature



In article <PHIL.95May12090139@peace.med.ohio-state.edu>,
 phil@peace.med.ohio-state.edu (Phil) writes:
>   IF NOT(keyowrd_set(key)) THEN BEGIN
>      ;set a default value here
>   ENDIF
>
>The problem comes in if the user wants to set key = 0.  If so then it
>appears to the above test that the keyword is not set even though in
>the function call the user typed
>  

I joined this thread late, but I assume you are using IDL rather than PV-Wave.
If this is the case then the following may not be of immediate use, but might
make RSI think a bit.

keyword_set returns zero in two cases:
1	when the parameter is not present
2	when the parameter is present and zero (or undefined)

n_elements returns zero in two cases:
1	when the parameter is not present
2       when the parameter is present but is an undefined variable
	(as may be the case for output parameters)


PV-Wave provides a function which can be used to distinguish these cases
Param__present  returns FALSE for both case 2's and TRUE for both case 1's.

As I said, this may not help you IDL users other than confirming that without
such a function it is impossible to unambiguously determine the status of a
parameter without a function such as PARAM_PRESENT.

COMPLAIN TO RSI!!!!

Alan Bell
bela@tessella.co.uk