I 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" );<BR /><BR />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 ) );
);