Hi

 

I’m using 4D 17.4 and I’ve just started to try to wrap my head around object 
notation and collections. Here’s a simplified object:

 

{

item_1:value,

item_2:value,

my_array:[

{

element_1_:value,

element_2:value,

element_3:value

},

{

element_1:value,

element_2:value,

element_3:value

 

}

]

}

 

I added the array to the object using OB SET ARRAY as I don’t think there’s a 
way to add an array to an object using object notation?

 

and can access and change the values correctly like this:

 

$object.item_1 := ”value”

$object.my_array[0].element_1 := ”value”

 

However, I’m struggling to figure out how to remove an element from the array. 

 

I want to remove the second element from “array” but I can’t see how to do that 
– either using object notation or the old school commands.

 

The only way I can see right now is to extract the array using OB Get Array, 
delete the unwanted element and then put the array back inside the object.

 

I’m also a bit hazy on whether this array is actually now a collection once 
it’s been added to the object? I tried using $object.my_array[1].remove() but 
just got an error

 

Sorry for the newbie nature of the question – I’ve been developing in 4D on and 
off for about 25 years but haven’t got to grips with object notation or 
collections just yet.

 

TIA

 

James

**********************************************************************
4D Internet Users Group (4D iNUG)
New Forum: https://discuss.4D.com
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[email protected]
**********************************************************************

Reply via email to