How do I create a modal selection window with multiple selectionHello JMP community,
I need some help with the following: I have a table (dt) with a nominal numeric column (Values). I would like to create a window that displays the sorted unique values of the Values column. Then I would like to select one or multiple values return those and pass them to a Select Where function.
I am absolutely a beginner at JSL and your help is appreciated.
To solve this issue, I created a function SelectNumericValues as follows:
// function to create a modal window with selection functionality
SelectNumericValues = Function( {dt, column_name},
// Use Summarize to find unique values in the specified column
Summarize( unique_values = By( Column( dt, column_name ) ) );
// Calculate the maximum number of selections
max_selections = N Items( unique_values );
// Create a window for user selection
nw = New Window( "Select Values",
<
// call my function with table dt and nominal numeric column "Values"
selected_values = SelectNumericValues(dt, "Values");
dt_select = dt << Select Where( :Values == selected_values)
The window with the unique sorted values is correctly rendered:

And I can select one or multiple options. But I end up with these two errors:
- Send Expects Scriptable Object in access or evaluation of 'List' , {/*###*/"0", "1", "2"}
- Name Unresolved: Button in access or evaluation of 'Button' , Button( 1 ) /*###*/
Which suggest that I am not handling the buttons correctly in the SelectNumericValues function and that I am also incorrectly dealing with the returned values in the Select Where function.

As an additional question: how would I implement the requirement that at least one option should be selected (closing the modal window with none selected should either not be possible, or it would implicitly mean that all options are selected).
Thanks!
Paul
Automation and ScriptingWindowsRe: How do I create a modal selection window with multiple selectionI found a working solution. I made the following mistakes:
- the function SelectNumericValues returns a list of characters, not of numbers.
- the Select Where function call requires the function Contains to match the list of numbers.
- This line selected_values = nw << Show Window; in the SelectNumericValues function causes the button related error (I think)
As a result, I need to coerce the selected values to numeric. And I need to adjust the Select Where function call.
I find that this works correctly:
// Function to generate the user selection window for numeric values
SelectNumericValues = Function( {dt, column_name},
// Use Summarize to find unique values in the specified column
Summarize( unique_values = By( Column( dt, column_name ) ) );
// Calculate the maximum number of selections
max_selections = N Items( unique_values );
// Create a window for user selection
nw = New Window( "Select Values",
<I am happy to see additional improvements from other users.Re: How do I create a modal selection window with multiple selectionI think you need to look into using a Data Filter. It will do the display and the selection for you.
Re: How do I create a modal selection window with multiple selectionThanks Jim!
Based on your recommendation I created a script using the Data Filter function. Thanks for pointing me to it as it is a very useful function for interactive filtering of data.
The main functionality that my script is implementing is to create output (a journal, saved e.g. as a pdf document) based on the data after it is filtered by the user. In other words, there is no need here for any interactive, multi-variate, filtering. In that sense, the approach I have shared in this post is useful to me.
Paul