我有以下由另一個 jsl 檔案呼叫的函數:
ConfirmFiltering = Function({},
show(dtImp);
dtImp << Select Where(!Contains(parameterChoice, :Parameter));
);即使 show 指令的輸出是:
dtImp = DataTable("Details 2");在下面的行中我收到以下錯誤:
Send 在存取或評估 'Send' 時需要可編寫腳本的對象, dtImp << /*###*/SelectWhere( !Contains(parameterChoice, :Parameter ) ) /*###*/
對我來說這似乎很奇怪,即使將 dtImp 命令識別為 DataTable,在下一行它也會將其描述為非“可編寫腳本的對象”
這可能是範圍問題。我建議將您對 :Parameter 列的參考更改為
dtImp::Parameter
變數parameterChoice的值是多少?
parameterChoice 的值由我嘗試建立的加載項的最終使用者選擇。
它沒有解決問題,我認為根不在“選擇位置”命令中。即使我使用:
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。
parameterChoice 是定標器值(例如「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 用戶社區