大家好,我正在尝试使用循环在选项卡框中显示选项卡框
下面是我的代码,但是它不允许我使用数组,只允许使用变量。
New Window( "Result", display = Tab Box() );
For( j = 1, j <= N Items( stepname ), j++,
step = Substitute( Char( stepname[j] ), "DataTable(\!"Specname=", "" );
display << Add(
step,
main[j] = Tab Box(
)
);
从您的简短描述来看,您似乎正在尝试显示不同步骤的不同规格。 第一个脚本显示了一种使用数组进行选项卡的选项卡式显示的方法。
Names Default to Here(1);
steps= {"A", "B", "C", "D"};
step_aa = Associative Array(steps);
step_aa["A"] = {"1101", "1102", "1103", "1104"};
step_aa["B"] = {"2101", "2102", "2207", "2068", "270X"};
step_aa["C"] = {"37Z0", "3027", "3133"};
step_aa["D"] = {"4001", "4005", "4517"};
main={};
New Window( "Result", display = Tab Box() );
For( j = 1, j <= N Items( stepname ), j++,
display << Add(
steps[j], PanelBox("",
tb = Tab Box();
));
tb << Set OverFlow Enabled(0);
insert into(main,tb);
);
For( j = 1, j <= N Items( stepname ), j++,
for(k=1, k<=nitems(step_aa[steps[j]]), k++,
main[j] << Add (EvalInsert("Data Table(\!"Specname=^step_aa[steps[j]][k]^\!")"))
); // add for k
main[j] << set selected(1); //select the first tab
);
display << set selected(1);

但是,我认为更好的选择是使用带有 TreeNodes 的树。 下面是一个示例和结果显示。
Names Default to Here(1);
steps= {"A", "B", "C", "D"};
step_aa = Associative Array(steps);
step_aa["A"] = {"1101", "1102", "1103", "1104"};
step_aa["B"] = {"2101", "2102", "2207", "2068", "270X"};
step_aa["C"] = {"37Z0", "3027", "3133"};
step_aa["D"] = {"4001", "4005", "4517"};
roots = {};
For( j = 1, j <= N Items( steps ), j++,
root = TreeNode(stepname[j]);
insert into(roots, root);
);
For( j = 1, j <= N Items( steps ), j++,
For(k =1, k<=nitems(step_aa[steps[j]]), k++,
c = Tree Node( step_aa[steps[j]][k] );
roots[j] << Append(c);
);
);
New Window( "TreeBox Tests",
HListBox(
tree = Tree Box( roots, Size( 300, 200 ) ),
tb = TextBox()
)
);
tree << Set Node Select Script(
Function( {thistree, thisnode},
If( !Is Empty( thisnode ),
txt = thisnode << get label;
tb << set text ( EvalInsert("Data Table(\!"Specname=^txt^\!")") )
)
)
);