objects are references, so you can't use the same object over and over again,
as if they point to different things.

bad code:

ARRAY OBJECT($oo;0)
C_OBJECT($o)

For ($i;1;3)

OB SET($o;"value";$i)

APPEND TO ARRAY($oo;$o)

End for

good code #1:

ARRAY OBJECT($oo;0)
C_OBJECT($o)

For ($i;1;3)

OB SET($o;"value";$i)

APPEND TO ARRAY($oo;$o)
CLEAR VARIABLE($o)

End for

good code #2:

ARRAY OBJECT($oo;0)
C_OBJECT($o)

For ($i;1;3)

$o:=New object
OB SET($o;"value";$i)

APPEND TO ARRAY($oo;$o)

End for

---

OB SET implicitly creates a new object, if the passed object is null.
in the bad example, this only happens on the first iteration.

in good example #1, we clear the object after appending it,
so OB SET will create a new object again.

in good example #2, we explicitly create a new object.
the code is more legible, so this should be the preferred style,
unless your version does not have New object.

Oct 4, 2019 5:26、Chip Scheide via 4D_Tech 
<[email protected]<mailto:[email protected]>>のメール:

is it possible to use append array with an object array?
I was playing, and I do not see a way to get this to work.



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

Reply via email to