TRUE

From Director Online Wiki
Jump to: navigation, search

A Lingo predefined constant that is exactly equal to the integer 1.

There is absolutely no difference between typing 1 instead of TRUE. Simply use whichever makes the code easier to understand.

Note that Lingo does not have a boolean type. True and false are represented as the integer values 1 and 0 respectively.


Also note that because other languages use other values to represent TRUE (notably C and C++ use -1 because it is the bitwise opposite of 0) it is not a very good idea to write code such as this:

   if( suchAndSuch = TRUE ) then
       doSomething()
   end if

The usual interpretation of numbers as true or false is that zero is false and anything else is true. While the above certainly works for the value 1, if the value were 2, 3, -1, etc., then it would consider that value to be false. By convention that would be wrong.

Instead, it may be safer to write:

   if( suchAndSuch <> FALSE ) then
       doSomething()
   end if

A note about shorthand

In Lingo it is possible to write shorthand if statements, like so:

   if( suchAndSuch ) then
       doSomething()
   end if

However, this will generate a script error if the expression being tested is not an integer. For this reason it is still safest to use the longhand form:

   if( suchAndSuch <> FALSE ) then
       doSomething()
   end if

See Also

FALSE