A predicate expression is an expression that is evaluated as being “true” or “false” as part of a statement that controls program execution. IDL evaluates predicate expressions in the following contexts:

  • IF...THEN...ELSE statements
  • ? : inline conditional expressions
  • WHILE...DO statements
  • REPEAT...UNTIL statements

The definition of true and false for the different data types is as follows:

Data Type

True

False

Byte, integer, and long

Odd integers

Zero or even integers

Floating point and complex

Non-zero values

Zero

String

Any string with non-zero length

Empty string ("")

Heap variables (pointers and objects)

Non-null values

Null values

List and Hash

List or Hash has at least one member

List or Hash is empty

If the LOGICAL_PREDICATE compile option is set:

Data Type

True

False

Numerical values

Non-zero values

Zero

String or heap variables

Non-null values

Null values

See COMPILE_OPT for additional details on the LOGICAL_PREDICATE compilation option.

In the following example, the logical statement for the condition is a conjunction of two conditions:

IF (LON GT -40) AND (LON LE -20) THEN ...

If both conditions (LON being larger than –40 and less than or equal to –20) are true, the statement following the THEN is executed.