I'm upgrading some scripts to make better use of JMP 9 capabilities at the moment, and have hit a difficulty which could be either trivial or rather complex - I don't know which. In a nutshell, I need to be able to select a column of a data table from a list box and perform an action with it - no problem there - but I also need to allow for the possibility that the names of the data table from which I'm making the selection could be changed during the running of the script. The following is a considerably cut-down version of the part of the script which illustrates the problem:
clear log();
dt = new table("DT",
new column("AAA", numeric, values([1, 2, 3])),
new column("BBB", numeric, values([4, 5, 6])),
new column("CCC", numeric, values([7, 8, 9])),
);
Expr_Perform_Some_Action = expr(
// e.g. write the column name to the log;
selected_column = lb << get selected;
show(column(dt, selected_column) << get name)
);
lb_list = dt << get column names;
lb = listbox(lb_list, eval(Expr_Perform_Some_Action));
Expr_Reset_DT_to_ABC = expr(
column(dt, "DDD") << set name("AAA");
column(dt, "EEE") << set name("BBB");
column(dt, "FFF") << set name("CCC");
);
Expr_Reset_DT_to_DEF = expr(
column(dt, "AAA") << set name("DDD");
column(dt, "BBB") << set name("EEE");
column(dt, "CCC") << set name("FFF");
);
Expr_Repopulate_LB = expr(
// Get rid of all the old items in the list;
for(i=1, i<=nItems(lb_list), i++,
lb << set selected(i);
);
lb << remove selected;
// Replace them with the new ones;
lb_list = dt << get column names;
lb << append(lb_list);
);
nw = new window("My Window",
lb,
buttonbox("Reset Columns of DT to DEF", eval(Expr_Reset_DT_to_DEF); eval(Expr_Repopulate_LB)),
buttonbox("Reset Columns of DT to ABC", eval(Expr_Reset_DT_to_ABC); eval(Expr_Repopulate_LB))
);
nw << move window(600, 100); // Move it so we can see it;
The above runs as I want it to in JMP 8, but not in JMP 9 (or rather, it throws up as many errors as there are columns in the data table). I think I can see why it doesn't work: in JMP 9 my selecting an item in the list box (lb << set selected(i)) to remove it from the list is causing the action associated with making such a selection to be performed. The question is, how can I rescript it so that this doesn't happen?