The LOGICAL_OR function performs a logical OR operation on its arguments. It returns True (1) if either of its arguments are non-zero (non-NULL for strings and heap variables), and False (0) otherwise.

The LOGICAL_OR function is similar to the OR operator, except that it performs a logical “or” rather than a bitwise “or” on its arguments.

Note: LOGICAL_OR always returns either 0 or 1, unlike the OR operator, which performs a bitwise OR operation on integers, and returns one of the two arguments for other types.

Unlike the || operator, LOGICAL_OR accepts multi-element arrays as its arguments. In addition, where the || operator short-circuits if it can determine the result by evaluating only the first argument, all arguments to a function are always evaluated.


At the IDL Command Line, enter:


IDL Prints:

1   1   1   0


Result = LOGICAL_OR(Arg1, Arg2)

Return Value

Integer zero (false) or one (true) if both operands are scalars, or an array of zeroes and ones if either operand is an array.


Arg1, Arg2

The expressions on which the logical OR operation is to be carried out. The arguments can be scalars or arrays of any type other than structure.


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 Appendix D, “Thread Pool Keywords” for details.

Version History



See Also