Jeremy,

$o.array[1]  will do it.

Take note of the square brackets, and be  aware that the index starts from 0, 
not 1

However, what you are trying to do can be accomplished much easier using a key 
pair object without a matched arrays.

Before:
Array_Names{1} = "Tag_Name"
Array Values{1} = text    //all values must be the same type

New:

C_Object($0)

$0:=new object("Tag Name";"text";"a different Tag name ";453432;"Tag3";Current 
date)

If you need multiple different objects like that one, use collections

C_Collections($Settings)
$Settings:=new collection

$Settings.push(new object("Tag Name";"text";"a different Tag name 
";453432;"Tag3";Current date))
$Settings.push(new object("Tag Name";"Different text";"a different Tag name 
";5;"Tag3";Yesterday))

 Etc.

Lahav

-----Original Message-----
From: 4D_Tech <[email protected]> On Behalf Of Jeremy Roussak via 
4D_Tech
Sent: Monday, June 10, 2019 1:22 PM
To: 4D iNug Technical <[email protected]>
Cc: Jeremy Roussak <[email protected]>
Subject: Re: Arrays in objects

Kirk,

Thanks - very helpful. What I was hoping to do was to build a couple of text 
arrays in a method; return them in an object; and then use them directly in 
calls to HTTP methods, something like this:

C_OBJECT($headers)
$headers:=BuildHeaders // returns object containing matched arrays 
$status:=HTTP Get($url; $response; $headers.names; $headers.values)

Is that possible, or must I extract the names and values arrays from the 
returned object before use? I’m using v17R4.

Jeremy

> On 10 Jun 2019, at 19:47, Kirk Brooks via 4D_Tech <[email protected]> 
> wrote:
> 
> Jeremy,
> Depends on which version you are using. If you are in v17 then 'arrays 
> in objects' are essentially gone. They are collections now and you can 
> use dot notation with collections.
> Otherwise, yes 'arrays' are still arrays within the object.
> 
> It's possible to mix the nomenclatures in v17. You _can_ define an 
> object as use OB SET ARRAY but there is no advantage to doing so. It's 
> much better to use collections.
> 
> C_OBJECT($o)
> $o:=New object
> $o.array:=New collection
> 
> $o.array.push(1) // $o: {array: [1]}
> 
> 
> $x:=$o.array[0]  //  $x = 1
> 
> If you have some array of longints you want to append you can call OB 
> SET
> ARRAY($o;”array”;$arrayOfLongs) without an error and it will be a 
> collection.
> You could also call ARRAY TO COLLECTION($o.array;$arrayOfLongs)
> 
> 
> On Mon, Jun 10, 2019 at 11:37 AM Jeremy Roussak via 4D_Tech < 
> [email protected]> wrote:
> 
>> Are arrays within objects rather second-class properties? I know that 
>> I can put an array into an object using OB SET ARRAY, and I can 
>> retrieve it (all of it) using OB GET ARRAY, but is that all?
>> 
>> Can I use dot notation to refer to the arrays themselves, or to 
>> individual elements of the array?
>> 
>> C_OBJECT($o)
>> 
>> $o:=New object
>> OB SET ARRAY($o;”array”;$arrayOfLongs)
>> 
>> $o.array{1} - error
>> $o.array - error
>> $o[“array”] - error
>> 
> 
> --
> 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:[email protected]
> **********************************************************************

**********************************************************************
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]
**********************************************************************
**********************************************************************
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