Welcome to the Harris Geospatial product documentation center. Here you will find reference guides, help documents, and product libraries.


BOOLEAN

BOOLEAN

The BOOLEAN function returns a result equal to Expression converted to boolean.

Notes


  • A boolean variable is actually a variable of type byte with a special boolean flag.
  • The type code for boolean variables is 1 (the same as byte).
  • You can use the ISA function with the BOOLEAN keyword to determine if a variable is a boolean.
  • You can pass boolean variables into any IDL function that accepts byte data - the data will be treated as just an array of 0's or 1's.
  • When you use a boolean variable in a math expression, the boolean flag is ignored and the result will not be a boolean. The only exception is the logical negation operator "~", which preserves the boolean flag.
  • When changing elements within a boolean array, the values will be converted to either true (1) or false (0). See the rules under Return Value below.
  • HELP will print out the data type as BOOLEAN, even though the actual type is byte.
  • Implied print will print out the words "true" or "false" for boolean values. Normal print will print out the values 1 or 0.
  • If you save a boolean variable in an IDL SAVE file, and then restore that file in IDL 8.3 or earlier, the boolean flag will be quietly ignored and the variable will be restored as a simple byte variable.

Example


a = [0.0, 1.0, 0.0, 3.0]
b = BOOLEAN(a)
b[2] = "yes" ; equal to "true"
HELP, b
PRINT, b
PRINT, JSON_SERIALIZE(b)

IDL prints:

B  BOOLEAN   = Array[4]
0  1  1  1
[false,true,true,true]

Syntax


Result = BOOLEAN( Expression )

Return Value


Returns a boolean value or array of the same dimensions as the Expression. The following rules are used for conversion:

  • For numeric data, all non-zero values become true (1). Zero values become false (0).
  • For strings, all non-empty strings become true (1). Empty (null) strings become false (0).
  • For pointers or objects, all valid heap variables become true (1). Null pointers or objects become false (0).

Arguments


Expression

The expression to be converted to boolean. Expression can be any data type except structure.

Keywords


Thread Pool Keywords

This routine is written to make use of IDL’s thread pool, which can increase execution speed on systems with multiple CPUs. The values stored in the !CPU system variable control whether IDL uses the thread pool for a given computation. In addition, you can use the thread pool keywords TPOOL_MAX_ELTS, TPOOL_MIN_ELTS, and TPOOL_NOTHREAD to override the defaults established by !CPU for a single invocation of this routine. See Thread Pool Keywords for details.

Version History


8.4

Introduced

See Also


BOOLARR, BYTE, COMPLEX, DCOMPLEX, DOUBLE, FIX, FLOAT, LONG, LONG64, STRING, UINT, ULONG, ULONG64



© 2017 Exelis Visual Information Solutions, Inc. |  Legal
My Account    |    Buy    |    Contact Us