在 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"}};
我通常建议不要获取这样的值,并尝试以其他方式而不是动态创建变量名(例如存储对列表或关联数组的引用)。