Perhaps I'm missing some nuance of what's needed. But building on the suggestion from @jthi, you can do this kind of thing (where, once you have the current row selection 'doSomething' can be made to do whatever JSL is capable of):
NamesDefaultToHere(1);
// Original code . . .
dt = Open( "$SAMPLE_DATA/Students2.JMP" );
dt << Sort( By( 1 ), Order( Ascending ), replacetable( 1 ) );
New Column( "A" );
Column( "A" ) << Formula( If( Row() == 1 | name != Lag( name, 1 ), 1, If( Lag( A, 1 ) < 6, Lag( A, 1 ) + 1 ) ) );
dt << run formulas;
Column( "A" ) << deleteFormula;
dt << Sort( By( "A" ), Order( DEscending ), replacetable( 1 ) );
dt << delete rows( N Rows( Loc( dt[0, "A"] > 0 ) ) + 1 :: N Row( dt ) );
dt << Sort( By( 1, "A" ), Order( Ascending, Ascending ), replacetable( 1 ) );
gb = dt <<
Graph Builder(
Size( 528, 454 ),
Show Control Panel( 0 ),
Variables( X( :A ), Y( :height ), Overlay( :name ) ),
Elements( Points( X, Y, Legend( 8 ) ), Smoother( X, Y, Legend( 9 ) ) )
);
// New code . . .
// Row state handler function to do something
doSomething = Function({x}, {Default Local},
// 'x' is a column vector of row states that have just CHANGED. We just need those that are now selected . . .
selectedRows = [];
For( i = 1, i <= NRow(x), i++, If( Selected( Row State( x[i] ) ), selectedRows = VConcat(selectedRows, x[i]) ));
Print(x);
Print(selectedRows);
);
// Assign the handler to the table
rsh = dt << MakeRowStateHandler(doSomething);