Subscribe Bookmark RSS Feed

Insert value to Associative Array

pmroz

Super User

Joined:

Jun 23, 2011

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
mattf

Community Trekker

Joined:

Jun 23, 2011

Hi:

How about:

pmroz

Super User

Joined:

Jun 23, 2011

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

Community Trekker

Joined:

Jun 23, 2011

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