Hi,
I have a JSL code to append button boxes for row selection. The problem is that it keeps appending duplicate boxes even if only 1 row is selected. I only want to append 'n' box for 'n' selected rows. If no rows are selected then it should delete all the boxes in the table box
It added 10 boxes just by selecting 1 row.
Names Default To Here( 1 );
dt2 = Open( "$SAMPLE_DATA/Iris.jmp", invisible );
New Window( "",
H List Box(
Graph Builder(
Size( 653, 571 ),
Show Control Panel( 0 ),
Variables( X( :Sepal length ), Y( :Sepal width ), Overlay( :Species ) ),
Elements( Points( X, Y, Legend( 6 ) ) ),
SendToReport(
Dispatch( {}, "Sepal length", ScaleBox, {Min( 4.02451368343195 ), Max( 8.24903846153846 ), Inc( 1 ), Minor Ticks( 0 )} ),
Dispatch( {}, "Sepal width", ScaleBox, {Min( 1.75 ), Max( 5.00400457665904 ), Inc( 1 ), Minor Ticks( 0 )} )
)
),
Spacer Box( size( 10, 0 ) ),
Outline Box( "Petal Species",
Spacer Box( size( 0, 10 ) ),
Scroll Box(
size( 350, 150 ),
disoi = Table Box(
colbox = Col Box( "Species" ),
//imvinum = Number Col Edit Box( "iMINum", {} ),
)
),
disoi << set selectable rows( 0 ),
)
)
);
f = Function( {this},
dt2 << begin data update;
list = {};
checnro = N Items( dt2 << getselectedrows );
For( i = 1, i <= checnro, i++,
Insert Into( list, dt2:Species[dt2 << getselectedrows][i] );
);
For Each( {wascc, idx}, list,
//For( k = 1, k <= N Items( list ), k++,
colbox << append(
Eval(
Parse(
"ex" || Char( idx ) ||
" = Button Box( wascc
,
New Window( \!"Wikipedia\!",
<<Type( \!"Dialog\!" ),
li"
|| Char( idx ) || "= ex" || Char( idx ) ||
"<< Get Button Name();
Web Browser Box( Char( \!"https://en.wikipedia.org/wiki/Iris_\!" || li" || Char( idx )
|| ")
)
),
<<Underline Style( 1 );
)"
)
)
)
);
dt2 << end data update;
);
rs = dt2 << make row state handler( f );