列选择问题我正在创建一个可视化效果,将所有打开的文件名存储在一个列表框中。然后,我想选择一个特定的文件,并将该文件中的所有数字列显示在colListBox中。奇怪的是,这似乎只对我自己创建的文件有效,而对示例目录中的另外两个文件无效。我尝试将所选表设置为“当前数据表”,但我无法弄清楚如何在切换表时切换列。
目前,它加载我的 flaws.jmp 表的列,而不是其他列。
ns = newNameSpace();
// Get some Data
dt1 = Open( "$SAMPLE_DATA/Big Class.jmp" ); // JMP Library.
dt1 = Open( "$SAMPLE_DATA/Football.jmp" ); // JMP Library.
dt1 = Open( "defects.jmp" ); // Troy Local File.
// Get a list of open files
openDTs = {};
for(i=1, i<= nTable(), i++,
insertInto(openDTs, dataTable(i))
);
// Create File and Column Selector
selectionWindow = newWindow("Col Selection Test",
ns:tableBox = listBox("", << setwidth(200), << setNLines(5), maxSelected(1),
selectedTable = (ns:tableBox << getSelected)[1];
currentDatatable(dataTable(selectedTable));
colList = dataTable(selectedTable) << getColumnNames("Numeric");
show(colList);
ns:columnBox << setItems(colList);
);
ns:tableBox << setItems(openDTs);
ns:columnBox = colListBox({}, width(177), << setNLines(5), maxSelected(1));
hListBox(ns:tableBox, ns:columnBox);
);
当我选择“缺陷”时,我得到了以下所需的结果

但是,后续选择的其他表不会填充列

缺陷.jmp 表

我尝试了各种方法,但似乎没有任何效果???奇怪。
有什么建议吗?
自动化和脚本回复:列选择问题您必须替换 Col List Box,因为它将引用特定的数据表
Names Default To Here(1);
ns = New Namespace();
Open("$SAMPLE_DATA/Big Class.jmp");
Open("$SAMPLE_DATA/Football.jmp");
Open("$SAMPLE_DATA/Cars.jmp");
dts = Get Data Table List() << get name;
selectionWindow = New Window("Col Selection Test",
H List Box(
lb = List Box(
dts,
<< Set Width(200),
<< Set NLines(5),
maxSelected(1),
sel_vals = lb << Get Selected;
If(N Items(sel_vals) > 0,
(clb_collector << Child) << Delete Box();
clb_collector << Append(
clb = Col List Box(Datatable(sel_vals[1]),
<< Set Items(Data Table(sel_vals[1]) << Get Column Names("Numeric", "String")),
<< Set Data Type("Numeric"),
width(177),
<
<SETNLINES></SETNLINES>
回复:列选择问题太棒了,谢谢 Jarmo。
删除并重新添加。我怎么就没想到呢。
另外,我不知道函数“获取数据表列表()”非常方便:)
感谢您的快速回复。