列選擇問題我正在創建一個視覺化效果,將所有打開的檔案名稱儲存在列錶框中。然後我想選擇一個特定的文件並將該文件中的所有數字列顯示到 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。
刪除並重新附加。我怎麼沒想到這一點。
另外,我不知道函數“獲取數據表列表()”非常方便:)
感謝您的快速回覆。