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

Home » Public Forums » archive » logical_true vs nothing in an if statment
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: logical_true vs nothing in an if statment [message #85931 is a reply to message #85929] Wed, 18 September 2013 13:22 Go to previous messageGo to previous message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
On 9/18/13 2:07 PM, mynameismunka@gmail.com wrote:
> On Wednesday, September 18, 2013 12:53:44 PM UTC-7, Paul van Delst wrote:
>> See:
>>
>>
>>
>> http://www.exelisvis.com/docs/Definition_of_True_and_F.html
>>
>>
>>
>> Your "if i then..." example is well documented (if a little strange)
>>
>> behaviour.
>>
>>
>>
>> On 09/18/13 15:44, mynameismunka@gmail.com wrote:
>>
>>> Why is the behavior of the 'if' statement in idl like this? I
>>
>>> was under the impression putting nothing there is equivalent to
>>
>>> the logical_true() statment???!
>>
>>>
>>
>>>
>>
>>>
>>
>>> IDL> for i=0,10 do if i then print,'true' else print,'false'
>>
>>> false
>>
>>> true
>>
>>> false
>>
>>> true
>>
>>> false
>>
>>> true
>>
>>> false
>>
>>> true
>>
>>> false
>>
>>> true
>>
>>> false
>>
>>> IDL> for i=0,10 do if logical_true(i) then print,'true' else print,'false'
>>
>>> false
>>
>>> true
>>
>>> true
>>
>>> true
>>
>>> true
>>
>>> true
>>
>>> true
>>
>>> true
>>
>>> true
>>
>>> true
>>
>>> true
>>
>>>
>
> Thanks for the help.
>

But, you can change this behavior in selected routines with the
logical_predicate compile option:

IDL> for i = 0, 10 do if i then print, 'true' else print, 'false'
false
true
false
true
false
true
false
true
false
true
false
IDL> compile_opt logical_predicate
IDL> for i = 0, 10 do if i then print, 'true' else print, 'false'
false
true
true
true
true
true
true
true
true
true
true

Mike
--
Michael Galloy
www.michaelgalloy.com
Modern IDL: A Guide to IDL Programming (http://modernidl.idldev.com)
Research Mathematician
Tech-X Corporation
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: idl: turn string value into variable name part2
Next Topic: Reading large files with restore

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

Current Time: Sun Oct 12 11:56:06 PDT 2025

Total time taken to generate the page: 2.63562 seconds