如何編寫列匹配對話框腳本我有一個對話框,需要用戶匹配列對。 與我們在連接表中所做的非常相似。

具體示例 - 我有一組實驗測量的參數和一組理論預測。 這些數據來自不同的來源,並且列命名可以是任意的,因此我需要用戶將每個參數的理論與實驗進行匹配。
有關於如何編寫這部分腳本的示例嗎? 以及如何保留這些對以及以後如何使用它們?
到目前為止,我已經有了這個,我感興趣的是如何編寫綠框中的框腳本以反映匹配對(如上面的示例)以及如何保留這些對(2 個項目列表的列表?)以及如何刪除\召回他們等:

這是腳本:
dt = New Table( "Untitled 5",
Add Rows( 4 ),
Set Header Height( 46 ),
New Column( "X", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [1, 2, 3, 4] ) ),
New Column( "A_Theory", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [1, 3, 2, 3] ) ),
New Column( "B_Measured", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [4, 5, 6, 5] ) ),
New Column( "A_Measured", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [1, 4, 3, 4] ) ),
New Column( "B_Theory", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [4, 5, 3, 4] ) )
);
notImplemented = Expr(
win = New Window( "Feature Not Implemented Yet", <<MODAL></MODAL>
數據混合和清理回复:如何編寫列匹配對話框腳本根據應用程序的工作方式,在用戶按下運行/確定按鈕之前最好不要將值附加到列表中,因為用戶可能希望從列錶框中刪除值(當前不可能)。
我在此示例中添加了 Run 按鈕和 runExpr(如果沒有 JMP16,您可以將 Transform Each 修改為 For 循環,該循環會將值追加到列表中),刪除按鈕並在按下 Match 時清除 col 列錶框選擇:
Names Default To Here(1);
matchedList = {};
dt = New Table("Untitled 5",
Add Rows(4),
Set Header Height(46),
New Column("X", Numeric, "Continuous", Format("Best", 12), Set Values([1, 2, 3, 4])),
New Column("A_Theory", Numeric, "Continuous", Format("Best", 12), Set Values([1, 3, 2, 3])),
New Column("B_Measured", Numeric, "Continuous", Format("Best", 12), Set Values([4, 5, 6, 5])),
New Column("A_Measured", Numeric, "Continuous", Format("Best", 12), Set Values([1, 4, 3, 4])),
New Column("B_Theory", Numeric, "Continuous", Format("Best", 12), Set Values([4, 5, 3, 4]))
);
notImplemented = Expr(
a = (clb1 << get selected)[1];
b = (clb2 << get selected)[1];
clb1 << Clear selection;
clb2 << Clear selection;
lb << Append(a || "=" || b);
);
notImplemented2 = Expr(
lb << Remove Selected;
);
runExpr = Expr(
lb << get items;
lb_values = Transform Each({val}, lb << get items, Words(val, "="));
show(lb_values);
);
gui = Expr(
H List Box(
V List Box(
Panel Box("Theory",
clb1 = Col List Box(All, Nlines(5))
),
Panel Box("Experiment",
clb2 = Col List Box(All, Nlines(5))
)
),
Panel Box("Theory vs Experiment Matching",
H List Box(
Lineup box(N Col(1),
Button Box("Match", notImplemented),
Button Box("Remove", notImplemented2),
),
lb = List Box({}, Nlines(12))
)
),
Panel Box("Actions",
Button Box("Run",
runExpr;
)
)
)
);
fileLoad = New Window("Example", Show Menu(0), Show Toolbars(0), gui);
回复:如何編寫列匹配對話框腳本好的,它是這樣工作的:
notImplemented = Expr(
a = (clb1 << get selected)[1];
b = (clb2 << get selected)[1];
lb << Append(a || "=" || b);
matchedList[N Items( matchedList ) + 1] = Eval List ({a, b});
//Insert Into(matchedList, Eval List(columnPair));
Show(matchedList);
);回复:如何編寫列匹配對話框腳本還有一個問題。 我這樣修改腳本:
Names Default To Here(1);
matchedList = {};
dt = New Table("Untitled 5",
Add Rows(4),
Set Header Height(46),
New Column("X", Numeric, "Continuous", Format("Best", 12), Set Values([1, 2, 3, 4])),
New Column("A_Theory", Numeric, "Continuous", Format("Best", 12), Set Values([1, 3, 2, 3])),
New Column("B_Measured", Numeric, "Continuous", Format("Best", 12), Set Values([4, 5, 6, 5])),
New Column("A_Measured", Numeric, "Continuous", Format("Best", 12), Set Values([1, 4, 3, 4])),
New Column("B_Theory", Numeric, "Continuous", Format("Best", 12), Set Values([4, 5, 3, 4]))
);
notImplemented = Expr(
a = (clb1 << get selected)[1];
b = (clb2 << get selected)[1];
lb << Append(a || "=" || b);
Insert Into(matchedList, {a, b});
Show(matchedList);
);
gui = Expr(
H List Box(
V List Box(
Panel Box("Theory",
clb1 = Col List Box(All, Nlines(5))
),
Panel Box("Experiment",
clb2 = Col List Box(All, Nlines(5))
)
),
Panel Box("Theory vs Experiment Matching",
H List Box(
Button Box("Match", notImplemented),
lb = List Box({}, Nlines(12))
)
)
)
);
fileLoad = New Window("Example", Show Menu(0), Show Toolbars(0), gui);我得到這個:
matchedList = {a, b, a, b};當我期待這個時:
matchedList = {{"A_Theory", "A_Measured"}, {"B_Theory", "B_Measured"}}或者類似的東西,這樣我就可以迭代對。
我究竟做錯了什麼?
回复:如何編寫列匹配對話框腳本讓我嘗試一下。
然後稍後對這些列執行某些操作(例如,為每對繪製“Fit Y by X”)-可以將它們保留為列表的列表嗎?
columnPairs = {{A_Theory, A_Experiment}, {B_Theory, B_Experiment}};然後迭代它們還是有更好的選擇?
回复:如何編寫列匹配對話框腳本如果我不得不猜測,連接平台使用列錶框,當您添加列對時,它會在其中附加新值。
Names Default To Here(1);
dt = New Table("Untitled 5",
Add Rows(4),
Set Header Height(46),
New Column("X", Numeric, "Continuous", Format("Best", 12), Set Values([1, 2, 3, 4])),
New Column("A_Theory", Numeric, "Continuous", Format("Best", 12), Set Values([1, 3, 2, 3])),
New Column("B_Measured", Numeric, "Continuous", Format("Best", 12), Set Values([4, 5, 6, 5])),
New Column("A_Measured", Numeric, "Continuous", Format("Best", 12), Set Values([1, 4, 3, 4])),
New Column("B_Theory", Numeric, "Continuous", Format("Best", 12), Set Values([4, 5, 3, 4]))
);
notImplemented = Expr(
a = clb1 << get selected;
b = clb2 << get selected;
lb << Append(a[1] || "=" || b[1]);
);
gui = Expr(
H List Box(
V List Box(
Panel Box("Theory",
clb1 = Col List Box(All, Nlines(5))
),
Panel Box("Experiment",
clb2 = Col List Box(All, Nlines(5))
)
),
Panel Box("Theory vs Experiment Matching",
H List Box(
Button Box("Match", notImplemented),
lb = List Box({}, Nlines(12))
)
)
)
);
fileLoad = New Window("Example", Show Menu(0), Show Toolbars(0), gui);
//{col1, col2} = Words((lb << get items)[1], "=");

我只是快速地將腳本組合在一起,因此使用比變量更好的命名,防止在列列錶框中選擇多個值,並刪除列索引的硬編碼限制。 當您需要可以獲取的值時,可以使用 << 將項目獲取到列錶框引用,這將為您提供項目列表。 然後使用 Words() 將其進一步拆分為不同的部分。