Re: A simple IF statement question [message #42517 is a reply to message #42513] |
Mon, 14 February 2005 06:37   |
Benjamin Luethi
Messages: 22 Registered: December 2004
|
Junior Member |
|
|
Excerpt from the IDL help:
The definition of true and false for the different data types is as
follows:
- Byte, integer, and long: odd integers are true, even integers are false.
- Floating-point, and complex: non-zero values are true, zero values are
false.
The imaginary part of a complex number is ignored.
- String: any string with a nonzero length is true, null strings are false.
- Heap variables (pointers and object references): non-null values are
true,
null values are false.
In your case it's integer. So because 0, 2 and 24 are even they are
"false",
1 and 19 are "true" (odd).
Ben
On 14 Feb 2005 05:55:28 -0800, Andry William <andry_william@hotmail.com>
wrote:
> Dear IDL user,
>
> 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,....)?
>
> Thanks for any comments.
>
> Andry
--
Using Opera's revolutionary e-mail client: http://www.opera.com/m2/
|
|
|