We’re asking you to select a content label when starting a new topic in the Discussions area. Read more to find out why.
Choose Language Hide Translation Bar
Highlighted
pmroz
Super User

Insert value to Associative Array

Hello all,

The following code works in JMP 9 but not JMP 8:



Basically I need to put a value into a particular position in an associative array. It appears that in JMP 8, to build an associative array you need to insert values sequentially with INSERT INTO.

I have a workaround but I would really like to use this syntax, which is much more convenient.

Thanks,
Peter
3 REPLIES 3
Highlighted
mattf
Level V

Re: Insert value to Associative Array

Hi:

How about:

Highlighted
pmroz
Super User

Re: Insert value to Associative Array

Hi Matt,

That doesn't work - I want put the string "hello world" into the list pointed to by x["one"], in the first position. What I want to end up with is:

print(x["one"])

{"hello world", "a", "b"}

I have a workaround in place - I was curious if there was a JMP version 8 syntax that I wasn't aware of. The syntax I showed works in version 9 but not 8.

Regards,
Peter
Highlighted
mattf
Level V

Re: Insert value to Associative Array

Yes,

Now I see:
The below works - but coincidenently Insert replaces the first record - does order matter?
<-
x = associative array();
x["one"] = {"", "a", "b"};
x["two"] = {"", "d", "e"};

print(x);

newx = Remove(x, "one");
newx << Insert("Hello World", "a", "b");

print(newx);
-->

produces
x
Associative Array({{"one", {"", "a", "b"}}, {"two", {"", "d", "e"}}})

newx
Associative Array({{"Hello World", "a"}, {"two", {"", "d", "e"}}})


Bset,
-Matt