Re: Script to append a table using Column Switcher does not work with up and down arrowsThe script is being run as soon as the selection changes in the list and before the column switcher has actually switched the columns. You can see this if you add a Wait to the end of the Set Script. The table updates before the graph is switched. This is why you see the previous column switcher selection. Unfortunately, I don't know of any other way to trigger what you are looking for. There is currently a request in the JMP Wish List for this feature:
https://community.jmp.com/t5/JMP-Wish-List/Add-a-lt-lt-Set-Function-message-to-the-column-switcher/idi-p/212288
Re: Script to append a table using Column Switcher does not work with up and down arrowsActually, you could change:
var = cs << Get Current;
to:
var = NW["Plots"][ListBoxBox( 1 )] << Get Selected;
And that should work.
Re: Script to append a table using Column Switcher does not work with up and down arrowsThanks for pointing out when the script is run, Paul. Also for the link to the Wish List request.
Re: Script to append a table using Column Switcher does not work with up and down arrowsPaul, this is fantastic! It works! It appears that "var = NW["Plots"][ListBoxBox( 1 )] << Get Selected" does what I thought the "Get Current" command was supposed to do! Using the "Wait" statement as you suggested, I see that they two differ in when they execute. Thanks so much for your help!
Re: Script to append a table using Column Switcher does not work with up and down arrows
Re: Script to append a table using Column Switcher does not work with up and down arrowsGreat! Hopefully, in a future release, we can implement the Wish List request to attach a script directly to the Column Switcher.
Re: Script to append a table using Column Switcher does not work with up and down arrowsThat would be SO useful! Thanks again for your help!Script to append a table using Column Switcher does not work with up and down arrowsI have a Column Switcher that controls a plot produced by graph builder. I want to append a table that contains information related to the column selected in Column Switcher. My script works, so long as one selects the column in column switcher by clicking on it. If one scrolls through using the up and down arrow keys, the table that appears is always for the previous column switcher selection. I can't figure out why - any insight would be very helpful.
The actual application is complicated, but this script shows a contrived example of the issue. Check what happens to the column of values to the right if you click to select a column, versus if you scroll through using the up and down arrows.
Names Default To Here( 1 ); dt = Open( "$Sample_Data/Diabetes.jmp" );
dt << Select Rows(1::25); NW = New Window( "Total Cholesterol", OB = Outline Box( " Plots", HLB = H List Box( nSelected = N Rows( dt << Get Selected Rows ); dt_Subset = dt << Subset( Selected Rows( 1 ) ); colList = {BMI, BP, Total Cholesterol, LDL, HDL, TCH, LTG}; GBobj = dt_Subset << Graph Builder( Size( 534, 456 ), Show Control Panel( 0 ), Variables( X( :Age ), Y( :BMI ) ), Elements( Points( X, Y, Legend( 3 ) ), Smoother( X, Y, Legend( 4 ) ) ) ); ); ); ); //Add column Switcher to GB plots Current Data Table( dt_Subset ); cs = GBobj << Column Switcher( :BMI, colList ); // Add initial table with values for Column Switcher selection for Age = 50 var = cs << Get Current; dt_Small = dt_Subset << Select Where( :Age == 50 ); dt_View = dt_Subset << Subset( Selected Rows( 1 ), Columns( var ), Invisible ); View1 = Data Table Box( dt_View ); Try( HLB << Append( View1 ) ); // Add script to act based on current Column Switcher selection; // Append/update the table NW["Plots"][ListBoxBox( 1 )] << Set Script( Try( Close( dt_View, NoSave ) ); Try( View1 << Delete ); var = cs << Get Current; dt_Small = dt_Subset << Select Where( :Age == 50 ); dt_View = dt_Subset << Subset( Selected Rows( 1 ), Columns( var ), Invisible ); View1 = Data Table Box( dt_View ); Try( HLB << Append( View1 ) ); );