選擇表,然後選擇列您好,我是 JMP 和 JSL 的新手,我在建立一個腳本來選擇一個表,然後選擇 2 列,然後對其執行某些操作時遇到問題。
這是一個例子
Names Default to Here( 1 );
// Make list of current tables
dtNames = {};
For(t=1, t<=NTable(), t++,
InsertInto(dtNames, DataTable(t) << getName);
);
// Select the table
nw = New Window("Test", <<MODAL> 0,
Print("Table selected: "||dtName[1]),
Print("No table selected")
)
);
/* Here I tried several options like
current data table (dt);
dt << get data table;
and other but I cannot find what fits well */
xvar = .;
yvar = .;
win = New Window( "Compared Values",
<<MODAL></MODAL></MODAL>在此範例中,我正在嘗試一個簡單的腳本,我可以在其中選擇一個已開啟的表,選擇 2 列,然後繪製一個簡單的圖。 但是,我無法使程式識別我選擇的特定表。
將來我將需要同時與幾個表進行交互,並從不同的表中選擇不同的列來獲取結果。 我認為這個腳本會是一個簡單的開始。 如果有人也能為我提供一個簡短的解釋,解釋為什麼我無法選擇我在第一個框中選擇的表,或者如何改進它,以及我的腳本的解決方案,我將非常感激。
謝謝!
自動化和腳本編寫分享和交流成果回覆:選擇表,然後選擇列我建議您閱讀腳本指南中有關模式視窗的內容。老實說,我建議您閱讀整個腳本指南。
幫助==>JMP 文件庫
回覆:選擇表,然後選擇列非常感謝,你的例子澄清了我的大部分問題。 我的主要問題是如何指向表格以使我的程式碼工作,現在我看到所有這些不同的選項非常清楚我的錯誤在哪裡。
還有一件事,當你說“模態視窗有一些帶有“確定”和“取消”按鈕的預設操作”,您建議我如何了解更多? 我有腳本指南,但我沒有閱讀它,您認為我可以在那裡找到它嗎? 或您建議其他來源嗎?
謝謝!
回覆:選擇表,然後選擇列你好,
我發現您的原始腳本有其他問題,我認為我已經解決了(例如,對 Col 列錶框中的資料表的引用不正確)
這是我的解決方案,從編碼的角度來看,它仍然可能有點笨拙:
Names Default to Here( 1 );
show (dt);
// Make list of current tables
dtNames = {};
For(t=1, t<=NTable(), t++,
InsertInto(dtNames, DataTable(t) << getName);
);
// Select the table
nw = New Window("Test", <<MODAL> require the user to select two variables before clicking OK
Text Box( " Select test values. " ),
H List Box(
Text Box( "Select Variable " ),
x = Col List Box(
Data Table (dtxt), // data table reference > UPDATED the call to selected data table
all, // display all columns from the data table
xvar = (x << Get Selected)[1];
// get the name of the selected column before the window closes
Show( xvar );
),
Text Box( "Select ID" ),
y = Col List Box(
Data Table (dtxt), //> UPDATED the call to selected data table
all,
yvar = (y << Get Selected)[1];
Show( yvar );
)
)
);
Data Table (dtxt) << Graph Builder( // Added specific call to the seleted data table
Show Control Panel( 0 ),
Show Legend( 0 ),
Show Title( 1 ),
Variables( X( as column (xvar) ), Y( As Column (yvar) ) ),
Elements( Points( X, Y, Legend( 6 ) ) )
);</MODAL>回覆:選擇表,然後選擇列模態視窗有一些帶有“確定”和“取消”按鈕的預設操作,這可能會弄亂您認為正在發生的程式碼。我發現最好採用預設操作,並對我的程式碼進行簡單的調整以獲得我想要的。這是我對程式碼的表選擇部分的修改,以將選定的資料表設定為當前資料表,並將變數“dt”設定為指向資料表的指標。
Names Default to Here( 1 );
// Make list of current tables
dtNames = {};
For(t=1, t<=NTable(), t++,
InsertInto(dtNames, DataTable(t) << getName);
);
// Select the table
nw = New Window("Test", <<MODAL></MODAL>
@蒂埃里_S使用清單來解決問題的建議是一個很好的建議。不過,我的做法有點不同。我將數據表的完整引用保存在列表中,而不僅僅是名稱。
Names Default to Here( 1 );
// Make list of current tables
dtNames = {};
For(t=1, t<=NTable(), t++,
InsertInto(dtNames, data table(DataTable(t) << getName));
);
// Select the table
nw = New Window("Test", <<MODAL></MODAL>回覆:選擇表,然後選擇列非常感謝,但這並不能解決我的問題。 實際上我以前有一個這樣的腳本,我開始使事情變得複雜,因為我無法管理我的列列錶框將列列表更新到選定的資料表。 也許我的問題出在程式碼的那部分?回覆:選擇表,然後選擇列你好,
看起來您可能會透過建立下標將 dtlb 的輸出分配給 dt 來使事情變得複雜。
我想知道以下變體是否更適合您(不再需要“OKScript”
Names Default to Here( 1 );
// Make list of current tables
dtNames = {};
For(t=1, t<=NTable(), t++,
InsertInto(dtNames, DataTable(t) << getName);
);
// Select the table
nw = New Window("Test", <<MODAL></MODAL>