Hello 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",
<<Modal,
<<Return Result,
V List Box(
Text Box( "Select values for analysis:" ),
lb = List Box( unique_values, Max Selected( max_selections ) ),
H List Box(
Button Box( "OK",
selected_values = lb << Get Selected;
//nw << Close Window;
),
Button Box( "Cancel",
selected_values = {};
nw << Close Window;
)
)
)
);
// Wait for user input
selected_values = nw << Show Window;
// Return the selected values
selected_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