NSCannotCreateScriptCommandError (10)

I did a search in help and this site with no success. I have no idea what this script means. I have this code so that it will fire when the application begins. I also wrote this script when I click a button. It seems to work really well when I click the button, but I don;t know what I am doing incorrect. Please help this newbie.

property theChosenfolder : “Macintosh HD:users:Rupert:desktop:baird:customers”

on awake from nib theObject
tell window of theObject
delete every menu item of menu of popup button “popupbutton”
repeat with myItem in list folder theChosenfolder as alias without invisibles
make new menu item at end of menu of popup button “popupbutton” with properties {title:myItem, enabled:true}
end repeat
end tell
end awake from nib

what I have found since is that if I try to put that code in the awake from nib or open of the window I get this error. I have found out that it is an error that means “the application received an invalid or unrecognized Apple event” and I don’t know what to do about it.

Can someone please help a brother out?

First, make sure to add trailing slashes to your folder paths. That could be your only problem here.

Otherwise, which object are you attaching the awake from nib handler to? If it’s attached to the popup button, then the code is alright. If you’re connecting this to the application itself, you’d use “tell window “myWindow””. If it’s connected to the window, then you’d just use “tell theObject”. You may be referencing an app window that’s not there, or a window of the window, which isn’t possible.

You could use the “will open” handler of the window instead, which will re-create the list just before the window is displayed, every time it opens. Even better, put the code in a subroutine, and re-use it using many methods…

property theChosenfolder : "Macintosh HD:users:Rupert:desktop:baird:customers:" 

on awake from nib theObject
	createPopupMenu()
end awake from nib

on will open theObject
	createPopupMenu()
end will open

on clicked theObject
	if name of theObject is "refreshMenu" then
		createPopupMenu()
	end if
end clicked

on createPopupMenu()
	tell window "myWindow"
		delete every menu item of menu of popup button "popupbutton"
		repeat with myItem in (list folder theChosenfolder as alias without invisibles)
			make new menu item at end of menu of popup button "popupbutton" with properties {title:myItem, enabled:true}
		end repeat
	end tell
end createPopupMenu

Sorry about the wait… :rolleyes:
j

That worked great. Thanks a ton for the help.

That worked great by the way. I am now trying to get the name of the selected item in that popup and concatenate it on to the original string and do the same thing on a new popup.

Here is the code I am trying to use, but I keep getting an eerro -1708 and I can’t find any documentation on what that is. I have tried getting the name and title from the current menu item, but I am having no luck.

Thanks

on selection changing theObject
if the name of theObject is “popupbutton” then
tell window “myWindow” of theObject
set customername to the name of the current menu item of popup button “popupbutton”
delete every menu item of menu of popup button “templatepopup”
set customerfolderlist to (theChosenfolder as string) & “:” & customername as alias
repeat with myItem in (list folder customerfolderlist as alias without invisibles)
make new menu item at end of menu of popup button “templatepopup” with properties {title:myItem, enabled:true}
end repeat
end tell
end if

end selection changing