在 Collistbox() 上使用 Try() 時出錯基本上我正在構建一個包含不同顯示框的自定義交互式窗口,並且我正在嘗試使用 for 循環來簡化選擇輸入。 例如,我有一個組合框和一個 collistbox,我正在嘗試使用循環語句獲取兩者的輸入。 但是當我這樣做時,我得到了一個錯誤。 我寫的表達式不正確嗎? (附錯誤日誌)
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
New Window( "Col List Box Example",
vlistbox(
var1 = combobox({"one", "two", "three"}),
hlistbox(Col List Box( all, width( 250 ), maxSelected( 1 ) ),
var2 = Col List Box()
)
)
);
var2 << append("height");
AA = {"",""};
for(i=1,i<=2,i++,
temp1 = "var"||char(i);
eval(
substitute(
expr(try(AA[i] = expr.temp1 << get, AA[i] = expr.temp1 << get items)), //try to use get, if error, use get items
expr(expr.temp1),parse(temp1)
)
)
);
show(AA);
腳本Re: 在 Collistbox() 上使用 Try() 時出錯我認為您的 Try 不起作用,因為 << Get 在與 ListBoxBox 一起使用時不會出現錯誤(只是要記錄的消息)。 如果您想以這種方式獲取值,例如可以使用 << 類名:
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
New Window("Col List Box Example",
V List Box(
var1 = Combo Box({"one", "two", "three"}),
H List Box(Col List Box(all, width(250), maxSelected(1)), var2 = Col List Box())
)
);
var2 << append("height");
AA = {"", ""};
For(i = 1, i <= 2, i++,
temp1 = "var" || Char(i);
Eval(
Substitute(
Expr(
If(expr.temp1 << class name == "ComboBox",
AA[i] = expr.temp1 << get
,
AA[i] = expr.temp1 << get items
)
), //try to use get, if error, use get items
Expr(expr.temp1), Parse(temp1)
)
);
);
Show(AA); //AA = {1, {"height"}};
我通常建議不要獲取這樣的值,並嘗試以其他方式而不是動態創建變量名(例如存儲對列表或關聯數組的引用)。