Here is a stab at it:
lstSelectedRows = {};
dt = Open("$SAMPLE_DATA\semiconductor capability.jmp");
filepath = "$Desktop";
nw = New window("part test",
V List Box(
obj = dt << Partition(
Y(:NPN1),
X(:PNP1, :PNP2, :PNP3, :PNP4, :NPN2, :NPN3, :NPN4),
Method("Decision Tree")
),
HListBox(
TextBox("rows selected in node = "),
tb1 = TextBox("0"),
),
HListBox(
TextBox("total rows selected = "),
tb2 = TextBox("0")
),
ButtonBox("clear all selections",
clear_selections
, underlinestyle(1)
),
Button box("make splits",
make_splits_expr
);
)
);
// in the partition platform from any node you can select rows
// but we need to detect this event ... do it by detecting
// row state changes in the table
rs = dt << make row state handler(
function({a},
cdt = current data table();
sel = cdt << Get Selected Rows;
insertinto(lstSelectedRows,aslist(sel));
tmp = [=>];
insertInto( tmp, lstSelectedRows );
lstSelectedRows = tmp << getKeys; // <--- dedupe
tb1 << settext(char(nrows(sel)));
tb2 << settext(char(nitems(lstSelectedRows)));
)
);
obj << ShowGraph(0);
obj << SplitBest(4);
obj << Show Split Count(1);
obj << Show Split Prob(1);
clear_selections = Expr(
dt << Clear Selected;
tb1 << settext("0");
tb2 << settext("0");
lstSelectedRows = {};
);
make_splits_expr = Expr(
dt << select rows(lstSelectedRows);
sel_rows = dt << Get Selected Rows;
tb1 << settext(char(nrows(sel_rows)));
If(N Items(sel_rows > 0),
dtTemp = dt << subset(rows(), selected columns(0), output table("Selected"));
//Close(dtTemp, save(filepath || "\" || "badpopulation.jmp"));
dt << invert row selection;
sel_rows = dt << Get Selected Rows;
dtSEG = dt << subset(selected rows(1), selected columns(0), output table("Not Selected"));
//Close(dtSEG, save(filepath || "\" || "goodpopulation.jmp"));
);
dt << Clear Selected;
);
I might not have understood what you are trying to do and so I wont try and explain what is going on with the code - but if it is what you are trying to do I'm happy to give you an explanation of what's going on - just let me know. Some of the code is a bit ugly but just wanted to see if I could understand what you were trying to do. For my own convenience, instead of saving 2 tables to the desktop I create 2 (visible tables) titled 'selected' and 'not selected'.
-Dave