This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com

Home

 
4D v20.6
Undefined

Undefined 


 

Undefined ( expression ) -> Function result 
Parameter Type   Description
expression  Expression in Expression whose resulting value to be evaluated
Function result  Boolean in True = undefined, False = not undefined

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:

 C_OBJECT(vEmp)
 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



See also 

CLEAR VARIABLE

 
PROPERTIES 

Product: 4D
Theme: Language
Number: 82

This command can be run in preemptive processes

 
PAGE CONTENTS 
 
HISTORY 

Modified: 4D v11 SQL
Modified: 4D v16 R4

 
ARTICLE USAGE

4D Language Reference ( 4D v20)
4D Language Reference ( 4D v20.1)
4D Language Reference ( 4D v20.2)
4D Language Reference ( 4D v20.3)
4D Language Reference ( 4D v20.4)
4D Language Reference ( 4D v20.5)
4D Language Reference ( 4D v20.6)