Great script! To make it more generic you possibly would have to answer some extra questions:
- would you always use this on all tables which are open or should the user be able to pick the tables?
- how is the column defined which the specification limits will be set to? First column in table? Should user be able to pick them or maybe just let user set them to all continuous columns?
I would also start the script with Names Default To Here(1); to avoid some issues global namespace might cause.
You could also possibly "make" the customers utilize JMP's Manage Limits. "Issue" with this is that user would have to know to press Save to Column Properties and then press OK
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Abrasion.jmp");
dt <<Subset(
By(:Shift),
All rows,
Selected columns only(0)
);
Close(dt, no save);
For Each({dt_ref}, Get Data Table List(),
nw = New Window("Manage Limits for " || (dt_ref << get name) || " - :Abrasion" , << modal, dt_ref << Manage Limits(Process Variables(:Abrasion)));
);
And for "generic" version which would just take all tables
Names Default To Here(1);
For Each({dt_ref}, Get Data Table List(),
New Window("Manage Limits for " || (dt_ref << get name) || " - :Abrasion" , << modal, dt_ref << Manage Limits(Process Variables(dt_ref << Get Column Names("Continuous"))));
);
I would most likely at least provide users the option to pick which tables to use so it would be something like this when using manage limits
Names Default To Here(1);
dtlist = Get Data Table List();
dtnames = Transform Each({dtref}, dtlist,
dtref << get name
);
// I don't like using modal windows, but maybe it is fine in this case
nw = New Window("Pick tables to set spec limits to", << modal, << return result,
<< On Validate(
If(N Items(lb_tables << get selected) < 1,
New Window("Warning", << modal,
H List Box(align("center"),
Icon box("Warning"),
Text Box("Select at least one table or cancel"), << Set Window Icon("Warning")
)
);
0;
,
1;
);
),
Lineup Box(N Col(2),
Panel Box("Pick Tables",
lb_tables = Listbox(dtnames)
),
Panel Box("Actions",
Button Box("OK",
user_selections = lb_tables << get selected;
),
Button Box("Cancel")
)
)
);
If(nw["Button"] == 1,
For Each({tablename}, nw["lb_tables"],
dt_ref = Datatable(tablename);
New Window("Manage Limits for " || (dt_ref << get name) || " - :Abrasion" , << modal,
H List Box(align("bottom"),
ml = dt_ref << Manage Limits(Process Variables(dt_ref << Get Column Names("Continuous"))),
Lineup Box(N Col(1),
Button Box("OK",
ml << Save to Column Properties; // could be used to "force save"
),
Button Box("Cancel")
)
)
);
);
);
-Jarmo