Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSReceiverEvaluationScriptError: 4 (1) ==> another issue



What happens if you refer to the menu item by name? As in:

set title of menu item "myOwnMenuItem" of sub menu of menu item "firstMainMenuItem" of main menu to myOwnTextVariable

An NSReceiverEvaluationScriptError: 4 usually occurs when an element you are referring to can not be found. In such cases I always try to get to the bottom of things like this:

try
	set mainMenu to main menu
	get mainMenu
on error errorMessage
	error "Could not get main menu: " & errorMessage
end try

try
	set firstMainMenuItem to menu item "firstMainMenuItem" of mainMenu
	get firstMainMenuItem
on error errorMessage
	error "Could not get first main menu item: " & errorMessage
end try

try
	set subMenu to sub menu of  firstMainMenuItem
	get subMenu
on error errorMessage
	error "Could not get sub menu: " & errorMessage
end try

try
	set menuItem to menu item "myOwnMenuItem" of subMenu
	get menuItem
on error errorMessage
	error "Could not get menu item: " & errorMessage
end try


If this does not work I can only give you the advice to put trivial code like this into a try block and log the error that occurs to a file or the run log if you're running the application from Xcode. The user should not see errors like this, at least not if renaming the menu item is absolutely necessary and the application couldn't go on without it.


Adrian



On Jan 13, 2006, at 12:35 AM, Philip Aker wrote:

On 2006, Jan 12, at 12:28, David Hanauer wrote:

set title of menu item 2 of sub menu of menu item 1 of main menu to myOwnTextVariable

Try 'memu bar item'. Other than that, I wouldn't know.


Philip Aker http://homepage.mac.com/philip_aker

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-studio mailing list (Applescript- email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/applescript-studio/lists% 40macevangelist.de


This email sent to email@hidden


--
Adrian R. Foltyn
macevangelist.de

Weißgerbergasse 13
D-90403 Nürnberg

Telefon:     +49 911 479 7982
Mobil:         +49 179 134 6584
Fax:            +49 721 151 313 587

email@hidden

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-studio mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/applescript-studio/email@hidden

This email sent to email@hidden
References: 
 >NSReceiverEvaluationScriptError: 4 (1) ==> another issue (From: David Hanauer <email@hidden>)
 >Re: NSReceiverEvaluationScriptError: 4 (1) ==> another issue (From: Philip Aker <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.