I'm working through an example (my 2nd one...) in a book and I keep getting an error when I click the button that is associated with this code block below. The line in red causes the error NSReceiveEvaluationScriptError: 4(1). I've typed it out just like in the book.
I'm using Applescript Studio to create the app.
In Interface Builder, or otherwise, how to I determine where the name "textbox" or "main" get associated with the NSTextField or NSWindow? I expected to see them under the Inspector "Attributes" view, but I didn't see them under any of the Inspector views.
I googled the error and found several hits, but most pointed to poorly behaving applescripts that others had downloaded, and I'm pretty sure I don't have any of them.
I also use the Xcode debugger, thinking that it might show the button or text field attributes, but I didn't see them there either.
Thanks!
I'm using Applescript Studio to create the app.
In Interface Builder, or otherwise, how to I determine where the name "textbox" or "main" get associated with the NSTextField or NSWindow? I expected to see them under the Inspector "Attributes" view, but I didn't see them under any of the Inspector views.
Code:
on clicked theObject
[color=red]set question to contents of text field "textbox" of window "main"[/color]
if question = "" then
display dialog "Sorry, but you did not ask a question. Please try again." buttons {"OK"}
return
end if
set randomNo to random number from 1 to 3
if randomNo = 1 then
set answer to "Yes"
end if
if randomNo = 2 then
set answer to "No"
end if
if randomNo = 3 then
set answer to "Maybe"
end if
beep
display dialog "question: " & question & "Answer: " & answer buttons {"OK"}
end clicked
I googled the error and found several hits, but most pointed to poorly behaving applescripts that others had downloaded, and I'm pretty sure I don't have any of them.
I also use the Xcode debugger, thinking that it might show the button or text field attributes, but I didn't see them there either.
Thanks!