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

Home

 
4D v20.6
OB Entries

OB Entries 


 

OB Entries ( object ) -> Function result 
Parameter Type   Description
object  Object in Object to return contents
Function result  Collection in Collection of objects with key / value properties

The OB Entries command returns a collection of objects containing the contents of the object as key / value property pairs. 

Each returned object contains the following properties:

 

PropertyTypeDescription
keystringenumerable property name of the object
valuevariantenumerable property value of the object

 

Only first-level property names are returned (property names of sub-objects are not returned). The order of properties within the returned collection follows the definition order of the properties.

Example  

Using an object as an hash map (key / value system) provides a quick and direct access to data, just like when using an index (e.g., if we need Mary's age, we can write: $persons["Mary"])

 C_OBJECT($individual;$persons)
 C_COLLECTION($names;$ages)
 
 $persons:=New object
 $persons["John"]:=42
 $persons["Andy"]:=24
 $persons["Mary"]:=30
 $persons["Paul"]:=50
 
 ALERT("The average age is "+String(OB Values($persons).average()))
 ALERT("There are "+String(OB Keys($persons).length)+" persons")
 
 $ages:=OB Entries($persons).query("value>:1";25)
 ALERT("There are "+String($ages.length)+" persons who are over 25")
 
 ALERT("Their names are: "+$ages.extract("key").join("-"))



See also 

OB Keys
OB Values

 
PROPERTIES 

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

 
PAGE CONTENTS 
 
HISTORY 

Created: 4D v18 R3

 
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)