Since the appearance of ORDA, classes, and other objects, you must work increasingly with undefined values.
Since some of you are asking for an easier way to use them, starting with v20, you can compare any type of value to an undefined value without throwing an error.
Usually, 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:
As mentioned before, we understand that when working with classes and objects, you must work with undefined values, so we have made this rule more flexible. Starting with v20, you can compare undefined values with all variable types:
- The = comparison returns true when you compare an undefined variable with a null or undefined value and false in all the other ways:
$o:=new object
If ($o.undefined =10)
...
else
// returns false because $o.undefined is undefined
...
End if
- The # comparison returns false when you compare an undefined variable with a null or undefined value and true in all the other ways:
$o:=new object
If ($o.undefined #10)
// returns true because $o.undefined is undefined
...
else
...
End if
- 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.
$o:=new object
If ($o.undefined >10)
...
else
// returns false because $o.undefined is undefined
...
End if
Check out the documentation for more details!