4D v16.3

OB GET PROPERTY NAMES

Home

 
4D v16.3
OB GET PROPERTY NAMES

OB GET PROPERTY NAMES 


 

OB GET PROPERTY NAMES ( object ; arrProperties {; arrTypes} ) 
Parameter Type   Description
object  Object, Object Field in Structured object
arrProperties  Text array in Property names
arrTypes  Longint array in Property types

The OB GET PROPERTY NAMES command returns, in arrProperties, the names of the properties contained in the language object designated by the object parameter.

object must have been defined using the C_OBJECT command or designate a 4D object field.

Pass a text array in the arrProperties parameter. If the array does not exist, the command creates and sizes it automatically. 

Optionally, you can also pass a longint array in arrTypes. For each element of arrProperties, the command returns, in arrTypes, the type of value stored in the property. You can compare the values received with the following constants, found in the "Field and Variable Types" theme:

Constant Type Value
Is Boolean Longint 6
Is JSON null Longint 255
Is object Longint 38
Is real Longint 1
Is text Longint 2
Object array Longint 39

You want to test that an object is not empty:

 ARRAY TEXT(arrNames;0)
 ARRAY LONGINT(arrTypes;0)
 C_OBJECT($ref_richard)
 OB SET($ref_richard;"name";"Richard";"age";7)
 OB GET PROPERTY NAMES($ref_richard;arrNames;arrTypes)
  // arrNames{1}="name", arrNames{2}="age"
  // arrTypes{1}=2, arrTypes{2}=1
 If(Size of array(arrNames)#0)
  // ...
 End if

Using an object array element:

 C_OBJECT($Children;$ref_richard;$ref_susan;$ref_james)
 ARRAY OBJECT($arrayChildren;0)
 
 OB SET($ref_richard;"name";"Richard";"age";7)
 APPEND TO ARRAY($arrayChildren;$ref_richard)
 OB SET($ref_susan;"name";"Susan";"age";4;"girl";True//additional attribute
 APPEND TO ARRAY($arrayChildren;$ref_susan)
 OB SET($ref_james;"name";"James")
 OB SET NULL($ref_james;"age") //null attribute
 APPEND TO ARRAY($arrayChildren;$ref_james)
 
 OB GET PROPERTY NAMES($arrayChildren{1};$arrNames;$arrTypes)
  // $arrayChildren{1} = {"name":"Richard","age":7}
  // $arrNames{1}="name"
  // $arrNames{2}="age"
  // $arrTypes{1}=2
  // $arrTypes{2}=1
 
 OB GET PROPERTY NAMES($arrayChildren{2};$arrNames;$arrTypes)
  // $arrayChildren{3} = {"name":"Susan","age":4,"girl":true}
  // $arrNames{1}="name"
  // $arrNames{2}="age"
  // $arrNames{3}="girl"
  // $arrTypes{1}=2
  // $arrTypes{2}=1
  // $arrTypes{3}=6
 
 OB GET PROPERTY NAMES($arrayChildren{3};$arrNames;$arrTypes)
  // $arrayChildren{3} = {"name":"James","age":null}
  // $arrNames{1}="name"
  // $arrNames{2}="age"
  // $arrTypes{1}=2
  // $arrTypes{2}=255



See also 

OB Get type
OB SET NULL

 
PROPERTIES 

Product: 4D
Theme: Objects (Language)
Number: 1232

This command can be run in preemptive processes

 
HISTORY 

Created: 4D v14
Modified: 4D v15

 
ARTICLE USAGE

4D Language Reference ( 4D v16)
4D Language Reference ( 4D v16.1)
4D Language Reference ( 4D v16.2)
4D Language Reference ( 4D v16.3)