| 4D v18ARRAY TO COLLECTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 
 | 
    4D v18
 ARRAY TO COLLECTION 
         | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ARRAY TO COLLECTION ( collection ; array {; propertyName}{; array2 ; propertyName2 ; ... ; arrayN ; propertyNameN} ) | ||||||||
| Parameter | Type | Description | ||||||
| collection | Collection |   | Collection to receive the array data | |||||
| array | Array |   | Array to copy to the collection; if propertyName passed, array to copy to the values of propertyName in the collection | |||||
| propertyName | Text |   | Object property name whose value to fill with array elements | |||||
The ARRAY TO COLLECTION command copies one or more array(s) into the elements or the propertyName values of collection.
This command can work with a collection that contains values or a collection that contains objects, in which case the propertyName parameter(s) are mandatory.
You want to copy a text array in a collection:
 C_COLLECTION($colFruits)
 $colFruits:=New collection
 ARRAY TEXT($artFruits;4)
 $artFruits{1}:="Orange"
 $artFruits{2}:="Banana"
 $artFruits{3}:="Apple"
 $artFruits{4}:="Grape"
 ARRAY TO COLLECTION($colFruits;$artFruits)
  //$colFruits[0]="Orange"
  //$colFruits[1]="Banana"
  //...You want to copy field values in a collection of objects through arrays:
 C_COLLECTION($col)
 $col:=New collection
 ARRAY TEXT($artCity;0)
 ARRAY LONGINT($arLZipCode;0)
 SELECTION TO ARRAY([Customer]City;$artCity)
 SELECTION TO ARRAY([Customer]Zipcode;$arLZipCode)
 ARRAY TO COLLECTION($col;$artCity;"cityName";$arLZipCode;"Zip")
  //$col[0]={"cityName":"Cleveland","Zip":35049}
  //$col[1]={"cityName":"Blountsville","Zip":35031}
  //...You want to copy a text array in a shared collection:
 ARRAY TEXT($at;1)
 
 APPEND TO ARRAY($at;"Apple")
 APPEND TO ARRAY($at;"Orange")
 APPEND TO ARRAY($at;"Grape")
 
 C_COLLECTION($sharedCol)
 $sharedCol:=New shared collection
 
 Use($sharedCol)
    ARRAY TO COLLECTION($sharedCol;$at)
 End use
									COLLECTION TO ARRAY
									
									Type conversions between collections and 4D arrays
									
	Product:  4D
	Theme:  Collections
	Number:  
        1563
        
        
        
	
	Created:  4D v16 R6
	
	
	
	
	
	
	
	
	
	4D Language Reference ( 4D v18)
	
	
	
	
	
 Add a comment
Add a comment