cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar

JMP 13 Using Loc() with a list - changed behaviour?

I have just upgraded to JMP 13 and it has made many custom scripts stop working. I have traced the problem to a change in how lists handle the result from a loc query. The code below used to return "pear" in JMP 12 but now returns {"pear"}.

 

mylist = {"apple","pear"};
mychoice = "pear";

showchoice = mylist[loc(mylist, mychoice)];

I was using the list[loc()] syntax to create SQL comma separated strings to execute stored procedures.

 

The new behaviour is logical if unexpected. Regrettably Loc() still won't take a list argument as the look up value - that would have been a beneficial outcome. How would you recommend to get the desired result:

  • convert the Loc() result to a number?
  • replace showchoice with showchoice[1] in my code?
  • other?

I could convert my list of choice(s) to a string and strip out the { & } & \!". This will not always work as the text list I show the user is not always the same as the list from which the corresponding key is picked for the SQL request.

1 ACCEPTED SOLUTION

Accepted Solutions

Re: JMP 13 Using Loc() with a list - changed behaviour?

I think that Loc() is supposed to take a matrix and return the location of true elements (non-zero).

Contains( list, item) works with lists and returns the location of the target item.

View solution in original post

4 REPLIES 4

Re: JMP 13 Using Loc() with a list - changed behaviour?

I think that Loc() is supposed to take a matrix and return the location of true elements (non-zero).

Contains( list, item) works with lists and returns the location of the target item.

Re: JMP 13 Using Loc() with a list - changed behaviour?

Replacing Loc() with Contains() fixed the issue. Thanks. I guess I had been doing too much Matrix manipulation when I wrote this section of code.

Re: JMP 13 Using Loc() with a list - changed behaviour?

David_Burnham
Super User (Alumni)

Re: JMP 13 Using Loc() with a list - changed behaviour?

This is abit like overfitting with predictive models. Your code is tuned to how JMP actually works as opposed to how it ought to work.  Which is fine, until the next release :-)

-Dave