将对象引用存储在列表中有没有人注意到,当你在列表中存储多个对象引用时,实际上并不能获取到这些对象引用……?
例如
Namesdefault to here(1);
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
gb = dt << Graph Builder( Variables( X( :height ), Y( :weight ) ), Elements( Points( X, Y ), Smoother( X, Y ) ) );
list = {};
list2 = {};
Insert Into(list, {gb, "test", "test2"});
Insert Into(list2, gb);
show(list[1]);
show(list2[1]);
show(gb);
输出:
list[1] = gb;
list2[1] = Graph Builder[];
gb = 图形构建器[];
第一个列表给出的是变量名,不能直接用来调用函数。
自动化和脚本编写回复:在列表中存储对象引用使用Eval List() ( 脚本指南 > 数据结构 > JSL 脚本中的列表 > 计算列表)
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
gb = dt << Graph Builder(
Variables(X(:height), Y(:weight)),
Elements(Points(X, Y), Smoother(X, Y))
);
list = {};
list2 = {};
Insert Into(list, Eval List({gb, "test", "test2"}));
回复:在列表中存储对象引用你做得好像太容易了。谢谢!