我有以下由另一个 jsl 文件调用的函数:
ConfirmFiltering = Function({},
show(dtImp);
dtImp << Select Where(!Contains(parameterChoice, :Parameter));
);即使 show 命令的输出是:
dtImp = DataTable("Details 2");在以下行我收到以下错误:
在访问或评估“发送”时,发送需要可编写脚本的对象,dtImp << /*###*/Select Where( !Contains(parameterChoice, :Parameter ) ) /*###*/
我觉得很奇怪,即使将 dtImp 命令识别为 DataTable,但在下一行它将其描述为非“可编写脚本的对象”
这可能是一个范围问题。我建议将对 :Parameter 列的引用更改为
dtImp::Parameter
变量parameterChoice的值是什么?
参数Choice 的值由我尝试创建的插件的最终用户选择。
它没有解决问题,我认为根源不在 Select Where 命令中。即使我使用:
dtImp << show window(1);
它给出了相同的错误。似乎它不允许对 DatatTble 使用 << 运算符。
但为了更具分析性,我有 2 个脚本:
Main.jsl:创建一个窗口,使最终用户能够使用按钮选择数据集
bboxImp = button box( "Select data to import", importData())
where the importData() function reads the data:
importData = Function({},
// Function that is used to select which data to import for the analysis
// Prompt the user to select input file
importFile = Pick File( "Select Excel data to import" );
if(importFile == "",
// No file was selected - we skip the rest
New window("Message", modal,
Text Box("No file has been selected for import")
),
// A file was selected - we continue
// Import data
dtImp = Open( importFile,
Worksheets( "Details" ),
Use for all sheets( 1 ),
Concatenate Worksheets( 0 ),
Create Concatenation Column( 0 ),
Worksheet Settings(
1,
Has Column Headers( 1 ),
Number of Rows in Headers( 1 ),
Headers Start on Row( 31 ),
Data Starts on Row( 32 ),
Data Starts on Column( 1 ),
Data Ends on Row( 0 ),
Data Ends on Column( 0 ),
Replicated Spanned Rows( 1 ),
Replicated Spanned Headers( 0 ),
Suppress Hidden Rows( 1 ),
Suppress Hidden Columns( 1 ),
Suppress Empty Columns( 1 ),
Treat as Hierarchy( 0 ),
Multiple Series Stack( 0 ),
Import Cell Colors( 0 ),
Limit Column Detect( 0 ),
Column Separator String( "-" )
)
);
// Select rows where "Component" column is empty
dtImp << Select Where( Is Missing( :Name( "Component" ) ) );
// Delete the selected rows
dtImp << Delete Rows;
// Grey out import botton and make Reimport and analysis botton available
wait(1);
dtImp << show window(0);
bboxImp << enable(0);
bboxRe << enable(1);
bboxAn << enable(1);
);
);
ImportRedo = Function({},
// Function that is used to remove imported datasets and allow for another import
// Close imported datafile and ungrey import and analysis botton
Close(dtImp, NoSave);
bboxImp << enable(1);
bboxRe << enable(0);
bboxAn << enable(0);
);然后,如果您按下“运行分析”按钮,它将调用 Analysis.jsl 脚本,该脚本创建一个窗口,最终用户可以在该窗口中进行一些选择,以选择各种唯一值来过滤数据。在此脚本中,在最终用户做出选择后,我尝试使用:
ConfirmFiltering = Function({},
show(dtImp);
dtImp << Select Where(!Contains(parameterChoice, :Parameter));
);过滤掉DataTable dtImp。
paramoteChoice 是否为诸如“xxx”之类的缩放值,或者是否为 JMP 列表值 {“xxx”}?
无论是哪种情况,如果是单个值,您可能需要将 Contains 的顺序更改为
</CODE></PRE>
<PRE><CODE class=" language-jsl">!Contains( :Parameter, parameterChoice )
您使用的是哪个 JMP 版本?您使用的是应用程序生成器吗?您如何处理范围和命名空间(我们没有看到完整的脚本,所以我们只能猜测)?当您从 .jsl 文件运行它时或在将其构建到插件中后,您是否遇到这些问题?如果您关闭 JMP 会话并运行脚本,第一次运行时是否遇到同样的问题?
提供完整代码很困难,所以我尝试描述并提供部分代码。但是,我理解,如果某人无法看到完整代码,则很难提供帮助。
我找到了解决方案。问题出在我上面提供的 Main.jsl 脚本中。在此脚本中,我有一个以下函数,当最终用户单击“运行分析”按钮时,该函数将被调用:
compatStudyEval = Function({},
// Function that is used to run the analysis script and handle landing page window
// Run the analysis script related to this add-in
Include( pathAddin || "\Analysis.jsl");
// Close landing page
win << close window;
);The problem is generated by the win << close window; command which I included to close the main window.
我发现解决方案受到以下帖子的启发:
已解决:名称未解决:访问或评估中的按钮 JMP 警报消息 - JMP 用户社区