Re: A simple IF statement question [message #42500] |
Mon, 14 February 2005 13:22  |
Mark Hadfield
Messages: 783 Registered: May 1995
|
Senior Member |
|
|
David Fanning wrote:
> David Fanning writes:
>> Here is an article you might want to read:
>>
>> http://www.dfanning.com/code_tips/bitwiselogical.html
>
> It has been pointed out to me that the article is a bit
> deficient in that it doesn't mention the LOGICAL_PREDICATE
> compiler option. If you set:
>
> COMPILE_OPT LOGICAL_PREDICATE
>
> Then 0 is FALSE and everything else is TRUE. That probably
> makes more sense to *everyone*! :-)
The article in question was written not longer before IDL 6.0 went into
beta and was intended to summarise some newsgroup explanations of IDL's
(very confusing) treatment of logical values. I suspect that the article
and/or the newsgroup explanations convinced RSI to clean things up. I've
been meaning to update the article for, oh, 2 years.
Setting COMPILE_OPT LOGICAL_PREDICATE *is* a good idea, I think (if you
have version 6.0 or greater). But there is a catch: the NOT operator can
no longer be used in logical expresssions. For example, 1 is always true
and "NOT 1" evaluates to "-2". this was false under the old rules but is
true when LOGICAL_PREDICATE is in effect. A logical not operator was
introduced in 6.0 and this always works, well, logically.
--
Mark Hadfield "Ka puwaha te tai nei, Hoea tatou"
m.hadfield@niwa.co.nz
National Institute for Water and Atmospheric Research (NIWA)
|
|
|