| This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 
 | 
    4D v20.6
 OB Entries 
         | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| OB Entries ( object ) -> Function result | ||||||||
| Parameter | Type | Description | ||||||
| object | Object |   | Object to return contents | |||||
| Function result | Collection |   | 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:
| Property | Type | Description | 
| key | string | enumerable property name of the object | 
| value | variant | enumerable 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.
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("-"))
	Product:  4D
	Theme:  Objects (Language)
	Number:  
        1720
        
        
        
	
	Created:  4D v18 R3
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	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)
	
	
	
 Add a comment
Add a comment