Undefined
Undefined ( expression ) : Boolean
Parameter | Type | Description | |
---|---|---|---|
expression | Expression | → | Expression whose resulting value to be evaluated |
Function result | Boolean | ← | True = undefined, False = not undefined |
Description
Undefined returns True if the result of the evaluation of expression is not a defined value, and False otherwise.
- A variable is defined if it has been created via a compilation directive or if a value is assigned to it. It is undefined in all other cases. If the database has been compiled, the Undefined function returns False for all variables.
- An object property is undefined if it does not exist in the object.
- Undefined always returns False for field references.
Note: Keep in mind that Undefined evaluates expression. The following statements are equivalent:
$result:=Undefined($exp)
// same result:
$result:=(Value type($exp)=Is undefined)
In some cases, you may not want the parameter to be evaluated (for example, when you use a pointer to a variable to check if the variable is defined). Then, you need to write:
$result:=(Type($ptr->)=Is undefined) //true if the pointed variable does not exist (no error)
Example
Here are the different results of the Undefined command as well as the Null command with object properties, depending on the context:
var vEmp : Object
vEmp:=New object
vEmp.name:="Smith"
vEmp.children:=Null
$undefined:=Undefined(vEmp.name) // False
$null:=(vEmp.name=Null) //False
$undefined:=Undefined(vEmp.children) // False
$null:=(vEmp.children=Null) //True
$undefined:=Undefined(vEmp.parent) // True
$null:=(vEmp.parent=Null) //True