选择表,然后选择列您好,我是 JMP 和 JSL 的新手,我在创建一个脚本来选择一个表,然后选择 2 列,然后对其执行某些操作时遇到问题。
这是一个例子
Names Default to Here( 1 );
// Make list of current tables
dtNames = {};
For(t=1, t<=NTable(), t++,
InsertInto(dtNames, DataTable(t) << getName);
);
// Select the table
nw = New Window("Test", <<MODAL> 0,
Print("Table selected: "||dtName[1]),
Print("No table selected")
)
);
/* Here I tried several options like
current data table (dt);
dt << get data table;
and other but I cannot find what fits well */
xvar = .;
yvar = .;
win = New Window( "Compared Values",
<<MODAL></MODAL></MODAL>在此示例中,我正在尝试一个简单的脚本,我可以在其中选择一个已打开的表,选择 2 列,然后绘制一个简单的图。 但是,我无法使程序识别我选择的特定表。
将来我需要同时与几个表进行交互,并从不同的表中选择不同的列来获取结果。 我认为这个脚本会是一个简单的开始。 如果有人也能为我提供一个简短的解释,解释为什么我无法选择我在第一个框中选择的表,或者如何改进它,以及我的脚本的解决方案,我将非常感激。
谢谢!
自动化和脚本编写分享和交流结果回复:选择表,然后选择列我建议您阅读脚本指南中有关模式窗口的内容。老实说,我建议您阅读整个脚本指南。
帮助==>JMP 文档库
回复:选择表,然后选择列非常感谢,你的例子澄清了我的大部分问题。 我的主要问题是如何指向表格以使我的代码工作,现在我看到所有这些不同的选项非常清楚我的错误在哪里。
还有一件事,当你说“模态窗口有一些带有“确定”和“取消”按钮的默认操作”,您建议我如何了解更多信息? 我有脚本指南,但我没有阅读它,您认为我可以在那里找到它吗? 或者您建议其他来源吗?
谢谢!
回复:选择表,然后选择列你好,
我发现您的原始脚本存在其他问题,我认为我已经解决了(例如,对 Col 列表框中的数据表的引用不正确)
这是我的解决方案,从编码的角度来看,它仍然可能有点笨拙:
Names Default to Here( 1 );
show (dt);
// Make list of current tables
dtNames = {};
For(t=1, t<=NTable(), t++,
InsertInto(dtNames, DataTable(t) << getName);
);
// Select the table
nw = New Window("Test", <<MODAL> require the user to select two variables before clicking OK
Text Box( " Select test values. " ),
H List Box(
Text Box( "Select Variable " ),
x = Col List Box(
Data Table (dtxt), // data table reference > UPDATED the call to selected data table
all, // display all columns from the data table
xvar = (x << Get Selected)[1];
// get the name of the selected column before the window closes
Show( xvar );
),
Text Box( "Select ID" ),
y = Col List Box(
Data Table (dtxt), //> UPDATED the call to selected data table
all,
yvar = (y << Get Selected)[1];
Show( yvar );
)
)
);
Data Table (dtxt) << Graph Builder( // Added specific call to the seleted data table
Show Control Panel( 0 ),
Show Legend( 0 ),
Show Title( 1 ),
Variables( X( as column (xvar) ), Y( As Column (yvar) ) ),
Elements( Points( X, Y, Legend( 6 ) ) )
);</MODAL>回复:选择表,然后选择列模态窗口有一些带有“确定”和“取消”按钮的默认操作,这可能会弄乱您认为正在发生的代码。我发现最好采用默认操作,并对我的代码进行简单的调整以获得我想要的。这是我对代码的表选择部分的修改,以将选定的数据表设置为当前数据表,并将变量“dt”设置为指向数据表的指针。
Names Default to Here( 1 );
// Make list of current tables
dtNames = {};
For(t=1, t<=NTable(), t++,
InsertInto(dtNames, DataTable(t) << getName);
);
// Select the table
nw = New Window("Test", <<MODAL></MODAL>
@蒂埃里_S使用列表来解决问题的建议是一个很好的建议。不过,我的做法有点不同。我将数据表的完整引用保存在列表中,而不仅仅是名称。
Names Default to Here( 1 );
// Make list of current tables
dtNames = {};
For(t=1, t<=NTable(), t++,
InsertInto(dtNames, data table(DataTable(t) << getName));
);
// Select the table
nw = New Window("Test", <<MODAL></MODAL>回复:选择表,然后选择列非常感谢,但这并不能解决我的问题。 实际上我以前有一个这样的脚本,我开始使事情变得复杂,因为我无法管理我的列列表框将列列表更新到选定的数据表。 也许我的问题出在代码的那部分?回复:选择表,然后选择列你好,
看起来您可能会通过创建下标将 dtlb 的输出分配给 dt 来使事情变得复杂。
我想知道以下变体是否更适合您(不再需要“OKScript”
Names Default to Here( 1 );
// Make list of current tables
dtNames = {};
For(t=1, t<=NTable(), t++,
InsertInto(dtNames, DataTable(t) << getName);
);
// Select the table
nw = New Window("Test", <<MODAL></MODAL>