Skip to main content
Version: 20 R7 BETA

OB Is defined

OB Is defined ( object {; property} ) : Boolean

ParameterTypeDescription
objectObject, ObjectStructured object
propertyTextIf passed = property to check, if omitted = check object
Function resultBooleanIf property omitted: True if object is defined, otherwise False.
If property passed: True if property is defined, otherwise False

Description

The OB Is defined command returns True if object or property is defined, and False otherwise.can be an object varialble or a 4D object field.

By default, if you omit the property parameter, the command checks whether the object is defined. An object is defined if its contents has been initialized.

Note: An object can be defined but empty. To find out if an object is undefined or empty, use the OB Is empty command.

If you pass the property parameter, the command checks whether this property exists in object. Note that the property parameter is case sensitive.

Example 1

Syntax testing the initialization of an object:

 var $object : Object
 $def:=OB Is defined($object) // $def=false since $object is not initialized
 
 OB SET($object;"Name";"Martin")
 OB REMOVE($object;"Name")
 $def2:=OB Is defined($object) // $def2=true since $object is empty {} but has been initialized

Example 2

Test for existence of a property:

 var $ref : Object
 OB SET($ref;"name";"smith";"age";42)
  //...
 If(OB Is defined($ref;"age"))
  //...
 End if

This test is equivalent to:

 If(OB Get type($Object;"name")#Is undefined)

See also

OB Is empty

Properties

Command number1231
Thread safe