cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Submit your abstract to the call for content for Discovery Summit Americas by April 23. Selected abstracts will be presented at Discovery Summit, Oct. 21- 24.
Discovery is online this week, April 16 and 18. Join us for these exciting interactive sessions.
Choose Language Hide Translation Bar
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
mattf
Level V

Re: Insert value to Associative Array

Hi:

How about:

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