一位客户询问如何创建 JSL 脚本来提示其他用户为每个子集表定义 LSL 和 USL。
我想不妨把脚本发布到这里,以便将来有同样需求的人能够得到帮助。如果您有任何反馈、疑问或改进建议,请随时留言。
// Subset data table
// → Data Table( "Product=B" )
dtList = Open("$SAMPLE_DATA/Abrasion.jmp")
<
<SUBSET></SUBSET>
很棒的脚本!为了让它更通用,你可能需要回答一些额外的问题:
- 您是否总是在所有打开的桌子上使用它,或者用户是否应该能够选择桌子?
- 如何定义要设置规格限值的列?表格中的第一列?用户是否应该能够选择它们,或者只是让用户将它们设置为所有连续的列?
我还将使用 Names Default To Here(1); 启动脚本,以避免全局命名空间可能导致的一些问题。
您也可以“让”客户使用 JMP 的“管理限值”功能。这样做的“问题”在于,用户必须知道点击“保存到列属性”,然后点击“确定”。
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Abrasion.jmp");
dt <
<SUBSET></SUBSET>
<P>对于“通用”版本,它只需要所有表格</P> <BR /> <BR /> <CODE class=" language-jsl">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"))));
);
我很可能至少会为用户提供选择使用哪些表的选项,因此在使用管理限制时它会是这样的
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")
)
)
);
);
);