Mail Search sample project and NSReceiverEvaluationScriptError

Hello, I’m brand new here. I’m new to AppleScript Studio, and relatively new to AppleScript, although I have a good background in other sorts of programming/scripting.

I was working my way through the AppleScript Studio Programming Guide, and things were going fine until I got to the the Mail Search tutorial. Naturally, I typed in the script myself, but when I got stuck with this NSReceiver thing, I copied and pasted the code provided with the sample project into my script, and got the same results. There were other oddities that I think I’ve worked out (like the sample code had a weird character in place of a “less than or equal to” character, and as far as I can tell it’s not neccessary to say “display panel window “status””, you can simply say “display panel “status””), but even the the script compiles it run into some sort of runtime error.

The error itself is:
AppleScript Error
NSReceiverEvaluationScriptError: 4 (1)

Through liberal use of commenting lines out and display dialogs, I was able to isolate the problem to this handler, and specifically the three lines noted with comments. When I comment out all three lines, I do not get the error (or any error). Naturally, the application won’t work :confused:

		on openPanel(statusMessage)
			if initialized is false then
				if not statusPanelNibLoaded then
					load nib "StatusPanel"
					set statusPanelNibLoaded to true
				end if
				tell window "status"
					-- THESE THREE LINES SEEM TO BE THE CULPRIT --
					set indeterminate of progress indicator "progress" to true
					tell progress indicator "progress" to start
					set contents of text field "statusMessage" to statusMessage
					-- ---------------------------------------- --
				end tell
				set initialized to true
			end if
			display panel "status" attached to theWindow
		end openPanel

I’ve noted some discussion on versions of Tiger breaking AppleScript Studio applications, but nothing that seems to really help me. Does anyone know why this would be happening, or can tell me how to fix it?

Model: PowerMac G5 dual 2.7, OS X 10.4.7
AppleScript: 1.10.7
Browser: Firefox 1.5.0.6
Operating System: Mac OS X (10.4)

drukepple, welcome to macscripter.:smiley:

As you work more and more with ASStudio, you will of course learn it’s intricacies, shortcomings, and inconsistencies. The 4(1) error you report is probably ASStudio’s most popular error. You’ll see these a lot, especially when you first start out. This is a generic error that means you are referencing an object incorrectly. Either you’ve typed in a name incorrectly, or no name is set for the object you’re referencing. Sometimes you have to work up the view chain to find the actual problem, especially when you have long references in one line. In your case, since it’s just a window tell block with a couple references made inside of that block, I’m guessing that you’ve either forgotten to name the progress indicator or the text field in IB, or you have typed the name wrong either in the script or in IB. Usually these errors are pretty simple to troubleshoot. Make sure too, that you’re actually naming them in the applescript pane, not just in the title or identifier field in IB. This is a common mistake, and an easy one to miss. Try commenting out all three lines, and then uncommenting one at a time. That will tell you which line(s) are actually not working, as it seems unlikely that all three have a problem.

Again welcome to macscripter, and let us know if you continue to have problems,

j

Thank you so much for the in depth reply, Jobu! It was very helpful and informative, thanks for taking the time to explain why it wasn’t working and not just how to fix it. It’s also encouraging to know that someday I’ll know what arcane error messages mean, if I see them enough!

Turns out the problem was almost exactly as you predicted…the problem not being a mis-named window or progress indicator object, but the nib file itself. It was “SatusPanel”, not “StatusPanel.” At least your input kicked me off in the right direction, looking for mis-typed pieces. Thanks again!

Unfortunately, though, the Mail Search app isn’t reading my mailboxes for some reason, but now that i’ve gotten to a point where it’s not erroring, at least I can troubleshoot that. I’ll post back if I can’t figure something out!