- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: JMP 13 Using Loc() with a list - changed behaviour?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: JMP 13 Using Loc() with a list - changed behaviour?
This might be helpful: https://community.jmp.com/t5/Discussions/JSL-Matrix-List-Programming-Change-for-JMP-13/m-p/18784
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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 :-)