KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Comparisons with an Undefined Value in 4D v20
PRODUCT: 4D | VERSION: 20 | PLATFORM: Mac & Win
Published On: August 29, 2023

Starting with 4D v20, you can now compare any type of value to an Undefined value without throwing an error.

Typically, in 4D the comparison operators =, #, >, <, >=, and <= check each operand’s type and value.

If the types of the two operands are different, the comparison throws an error.

Note:
The >, <, >= and <= comparisons return false for all the comparisons between an undefined variable and a scalar value (numeric, text, date, time, boolean). Because the comparison has no meaning, 4D throws an error for the other types.

Example:

$o:=new object
if ($o.undefined=10) // produces error previous to 4D v20
else
  // returns false because $o.undefined is undefined
end if


Example:
$o:=new object
if ($o.undefined#10)
  // returns true since $o.undefined does not equal 10
else
end if