你好,
我基本上是在嘗試訪問在函數中創建的變量。 我試圖在函數外部打印該變量,但不斷出現名稱未解析/已刪除引用“膠水”錯誤。 我基本上有一個按鈕函數,它創建一個新窗口並將 lf 的值存儲在該函數和窗口創建中。 我希望能夠打印 lf 的值,但我不知道如何打印。 任何建議,將不勝感激。 另一個問題是,當我在 OKscript1 函數內打印 lf 時,它不會打印到日誌中。 這是因為 OKscript1 不是函數而是 Expr 嗎? 另外,當我選擇文件後第一次運行該程序時,我收到名稱未解析的錯誤。 但是,當我再次運行它並選擇不同的文件並查看日誌時,我在退出之前選擇的上一個文件會出現在日誌中。 有什麼想法嗎? 我認為這可能是我忽略的一件非常簡單的事情,或者與我的範圍界定有關?
mainWindow = New Window("Instruction Tagger",
ob = Outline Box("Instruction Tagger",
Border Box(Left(3), top(2),
V List Box(
H List Box(
Panel Box("Please choose one of the following options:", <<MARKUP> 1), Throw ("Error: Please only select one measurement file. Alternitavely, go back and select 'Tag Multiple Files'. "));
if(Try(N Items(lf) < 1), Throw ("Error: Please select one measurement file.Alternitavely, go back and select 'Tag Multiple Files'."));
);
print(lf);
print(lf); </MARKUP>
你好@cwillden ,
非常感謝你的幫助。 我應該有一個標籤來使我的文本加粗,這就是我使用標記的原因,但我意識到我把它們去掉了。 為了保持一致性,我將投擲和文本框更改為標題。 再次感謝您的解釋。
你好@賈茲,
我修補了這個腳本上的縮進,因為它很難理解。我還刪除了 <
這裡有幾個問題:當您運行腳本時,它將在用戶對對話框進行任何操作之前運行底部的“print(lf)”行。當您要求 JMP 打印它時,“lf”甚至還不存在。您必須將其放在 OKScript1 表達式中,以便僅當用戶按“確定”時才運行該代碼行。
在從 ListF 獲取項目之前,您也無法關閉窗口,因為 ListF 將不再存在。您確實註釋掉了該行代碼,所以我不確定這是否導致您的“已刪除對象引用”錯誤。
下面的腳本似乎有效。我沒有收到任何錯誤,並且 print(lf) 正在工作。它顯示了我在日誌列表中選擇的文件。
mainWindow = New Window("Instruction Tagger",
ob = Outline Box("Instruction Tagger",
Border Box(Left(3), top(2),
V List Box(
H List Box(
Panel Box("Please choose one of the following options:",
Button Box("Tag a Single File", singleFileButton1("Tag Instructions to Data") ),
Button Box( "Tag Multiple Files", singleFileButton1("Tag Instructions to Data") ),
Text Box("Note: a button to tag the data will appear automatically after you have selected the measurement & PFD files. ")
)
)
)
)
)
);
singleFileButton1 = Function({x},
mainWindow << Close Window;
choosingFilesWindow = New Window(x,
ob = Outline Box("Select Your Files: ",
Border Box (Left(3), top(2)),
vDisplay = V List Box(
H List Box(
Panel Box("Please select one of the options below to choose your measurement & PFD file: ",
Button Box("Select Measurement File", selectMeasurementFileButton("Select Measurement File")),
Button Box("Select PFD File", selectPFDFileButton("Select PFD File")),
Lineup Box (N Col(2), Spacing(3)),
Panel Box("Files Added",
CB = Check Box({"Measurement file added", "PFD file added"},<<SET> 1), Throw ("Error: Please only select one measurement file. Alternitavely, go back and select 'Tag Multiple Files'. "));
if(Try(N Items(lf) < 1), Throw ("Error: Please select one measurement file.Alternitavely, go back and select 'Tag Multiple Files'."));
);</SET>我建議更改最後的“成功”if 語句。我不相信 CB << Set(1,0) 會被評估,因為您已經使用 Throw() 來停止進一步處理。考慮在該框中將 Throw() 替換為 Caption()。這也使得“成功”消息看起來不像 Throw() 那樣是錯誤。