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

Home » Public Forums » archive » A simple IF statement question
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: A simple IF statement question [message #42518 is a reply to message #42513] Mon, 14 February 2005 07:11 Go to previous messageGo to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
David Fanning writes:

> Andry William writes:
>
>> I am using IDL 6.1 on Linux SUSE. I am writing a simple code using the
>> IF statement and am wondering about the following result:
>>
>> IDL> IF 1 THEN PRINT, '1' ELSE PRINT, 'None'
>> 1
>> IDL> IF 2 THEN PRINT, '2' ELSE PRINT, 'None'
>> None
>> IDL> IF 19 THEN PRINT, '19' ELSE PRINT, 'None'
>> 19
>> IDL> IF 24 THEN PRINT, '24' ELSE PRINT, 'None'
>> None
>> IDL> IF 0 THEN PRINT, '0' ELSE PRINT, 'None'
>> None
>>
>> Am I wrong when I expect the IF statement to return always TRUE if the
>> condition is not 0 (I mean something like 1,2,3,4,....)?
>
> Yes, you are wrong. :-)
>
> 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*! :-)

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: test
Next Topic: strange things in CONTOUR

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

Current Time: Wed Oct 22 17:55:07 PDT 2025

Total time taken to generate the page: 0.88171 seconds