4D v17.4OB SET ARRAY | 
            ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 
                 
                
    
    
                 | 
                
			
                    
                         
    4D v17.4
 
OB SET ARRAY 
                                
                                
        
 | 
                |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| OB SET ARRAY ( objet ; propriété ; tableau ) | ||||||||
| Paramètre | Type | Description | ||||||
| objet | Champ objet, Objet | 
             
         | 
        Objet structuré | |||||
| propriété | Texte | 
             
         | 
        Nom de la propriété à définir | |||||
| tableau | Tableau, Variable | 
             
         | 
        Tableau à stocker dans la propriété | |||||
La commande OB SET ARRAY permet de définir le tableau à associer à la propriété dans l’objet de langage désigné par le paramètre objet.
objet doit avoir été défini via la commande C_OBJECT ou désigner un champ objet 4D.
Passez dans le paramètre propriété le libellé de la propriété à créer ou à modifier. Si la propriété existe déjà dans objet, sa valeur sera mise à jour. Si elle n’existe pas, elle est créée. Attention, le paramètre propriété tient compte des majuscules/minuscules.
Passez dans le paramètre tableau le tableau devant être passé comme valeur de la propriété. Plusieurs types de tableaux sont pris en charge : réel, entier long, texte, booléen, objet, pointeur ou image.
Notes :
Utilisation d’un tableau texte :
 C_OBJECT($Children)
 ARRAY TEXT($tabChildren;3)
 $tabChildren{1}:="Richard"
 $tabChildren{2}:="Susan"
 $tabChildren{3}:="James"
 
 OB SET ARRAY($Children;"Children";$tabChildren)
     // Valeur de $Children = {"Children":["Richard","Susan","James"]}Ajout d’un élément dans un tableau :
 ARRAY TEXT($tabText;2)
 $tabText{1}:="Smith"
 $tabText{2}:="White"
 C_OBJECT($Employees)
 OB SET ARRAY($Employees;"Employés";$tabText)
 APPEND TO ARRAY($tabText;"Brown") //Ajout dans le tableau 4D
     // $Employees = {"Employés":["Smith","White"]}
 
 OB SET ARRAY($Employees;"Employés";$tabText)
     // $Employees = {"Employés":["Smith","White","Brown"]}Utilisation d’un tableau texte avec sélection d’un élément :
     //$Employees = {"Employés":["Smith","White","Brown"]}
 OB SET ARRAY($Employees ;"Manager";$tabText{1})
     //$Employees = {"Employees":["Smith","White","Brown"],"Manager":["Smith"]}Utilisation d’un tableau objet :
 C_OBJECT($Enfants;$ref_richard;$ref_susan;$ref_james)
 ARRAY OBJECT($tabEnfants;0)
 OB SET($ref_richard;"nom";"Richard";"age";7)
 APPEND TO ARRAY($tabEnfants;$ref_richard)
 OB SET($ref_susan;"nom";"Susan";"age";4)
 APPEND TO ARRAY($tabEnfants;$ref_susan)
 OB SET($ref_james;"nom";"James";"age";3)
 
 APPEND TO ARRAY($tabEnfants;$ref_james)
 
     //$tabEnfants {1} = {"nom":"Richard","age":7}
     //$tabEnfants {2} = {"nom":"Susan","age":4}
     //$tabEnfants {3} = {"nom":"James","age":3}
 
 OB SET ARRAY($Enfants;"Enfants";$tabEnfants)
 
     // $Enfants = {"Enfants":[{"nom":"Richard","age":7},{"nom":"Susan",
     // "age":4},{"nom":"James","age":3}]}L’objet est représenté ainsi dans le débogueur :

Utilisation d'un champ objet :
 ARRAY TEXT($arrGirls;3)
 $arrGirls{1}:="Emma"
 $arrGirls{2}:="Susan"
 $arrGirls{3}:="Jamie"
 OB SET ARRAY([Personnes]Enfants;"Girls";$arrGirls)
									Conversions de type entre les collections et les tableaux 4D
									
									OB GET ARRAY
									
									OB SET
									
	Produit :  4D
	Thème :  Objets (Langage)
	Numéro :  
        1227
        
        
        
	
	Créé :  4D v14
	Modifié :  4D v15
	Modifié :  4D v16 R4
	
	
	
	4D - Langage ( 4D v17)
	
	
	
	
	4D - Langage ( 4D v17.1)
	
	4D - Langage ( 4D v17.2)
	
	4D - Langage ( 4D v17.3)
	
	4D - Langage ( 4D v17.4)
	
	
Ajouter un commentaire