Chip,
If you are using v15 OB SET ARRAY can set the native 4D arrays except for
pointers, I think. So if you set a text array you can get a text array
back. But the object property type is not concerned with the array type. As
far as OB GET TYPE is concerned any array is an object array.

In v17 it's treated like a collection. I really never used v16 a lot so I'm
not as familiar with what happens there.

In v17 you should really use collections. The OB SET ARRAY and OB GET ARRAY
methods are really for compatibility at this point. Collections offer so
much more flexibility since each element of a collection can be any type of
data. v15 will handle that but only very deep inside itself. By that I mean
you can import a JSON with a collection of mixed data types and 4D will
handle it but at the program level you can't manipulate or change anything.
In v17 you can.

Having worked with a lot of object arrays in v15 I agree with John that if
you need to search in the array and deal with different data types you will
want to build an object for each element. Something like: { name: "xyz",
value: <whatever the value is>} is good. This way you can have mixed data
types in the same object array.

Then you can us OB GET TYPE on the object:  OB GET TYPE($obj;"value") ->
whatever the type is.
The only way to search the array is by looping through it.

It's clunky compared to what you can do in v17 but the best approach I
found for v15.

You know I've seen a lot of JS code on other platforms where they tend to
treat anything in a JSON as a text value and type it when it's accessed.
It's not a bad approach.

On Mon, Oct 21, 2019 at 11:00 AM Chip Scheide via 4D_Tech <
4d_tech@lists.4d.com> wrote:

> John,
> thanks
>
> I was typing a reply, and realized I had not tested something.
> OB GET ARRAY(Object;Property;Object_Array) when the 'object array' is
> not an object array.
>
> if the array in the object is NOT an actual object array, then
> Object_Array is set to the size of the array inside the object, BUT all
> elements are 'undefined'.
>
> so..
> if I find an array, I can extract it into an object array, and if
> element 1 is undefined it is NOT an actual object array, and if element
> 1 is defined then it is an abject array and I can recursively call my
> new find in object array method!
>
> Chip
> On Mon, 21 Oct 2019 12:14:21 -0500, John DeSoi via 4D_Tech wrote:
> > You can't determine the type of the array. I think you can load any
> > type into a text array, but then you would have to convert it. The
> > best option for internal use is to include a property that indicates
> > the type, i.e. use "type" and "value" pairs.
> >
> > John DeSoi, Ph.D.
> >
> >
> >
> >> On Oct 21, 2019, at 11:27 AM, Chip Scheide via 4D_Tech
> >> <4d_tech@lists.4d.com> wrote:
> >>
> >> However, a longint array is NOT an object array, and vise verse.
> >> So.... how do you determine the type of an array inside an object?
> >
> > **********************************************************************
> > 4D Internet Users Group (4D iNUG)
> > Archive:  http://lists.4d.com/archives.html
> > Options: https://lists.4d.com/mailman/options/4d_tech
> > Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> > **********************************************************************
> We have done so much, with so little, for so long;
> We are now qualified to anything with nothing <sigh>
>   - unknown
> **********************************************************************
> 4D Internet Users Group (4D iNUG)
> Archive:  http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **********************************************************************



-- 
Kirk Brooks
San Francisco, CA
=======================

What can be said, can be said clearly,
and what you can’t say, you should shut up about

*Wittgenstein and the Computer *
**********************************************************************
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**********************************************************************

Reply via email to