X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 02 Oct 2007 11:04 AM by  anon
how to define a BOOL variable in IDL
 2 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
02 Oct 2007 11:04 AM
    I want to define a BOOL variable which just have 1 (ture) and 0 (False) in IDL, how can I accomplish this?

    Deleted User



    New Member


    Posts:
    New Member


    --
    02 Oct 2007 11:04 AM
    IDL recognizes 0 as logical false and 1 as logical true. The situation is similar to original C, where, if I remember correctly, there also was no (and perhaps still is no) "bool" datatype. In this case, it made sense for programs to have statements like: #define TRUE 1 #define FALSE 0 Same concept in IDL, where you could possibly set a definition like the above in an IDL COMMON block (see Online Help for "COMMON statement"). Alternatively, just have the expressions: TRUE = 1 FALSE = 0 at the beginning of your PRO or FUNCTION, then use syntax like: if result eq TRUE then ... The only reason to take this approach, however, is because you think it makes your code more easily READABLE. James Jones

    Deleted User



    New Member


    Posts:
    New Member


    --
    02 Oct 2007 11:04 AM
    Dear Oupin, Just to add to James' answer, I was thinking that another way could also be to define two new system variable: !true and !false. In IDL system variables are a special class of predefined variables that are available to all program untis. The way to define them is using the procedure DEFSYSV as follow: IDL> defsysv, '!true', 1B IDL> defsysv, '!false', 0B where the first argument is the name of the variable and the second is the value. I hope this helped. Fernando
    You are not authorized to post a reply.