Selecting an item in a popup button

Hi!

I’ve just started to write a program that tracks people’s running, and I have run into a snag.

When the user double-clicks on a table item, it opens up an edit panel, in which all the values are inserted automatically. (They are taken from an array.)

I can set all of the text fields fine, but when I try to set the menu item of the popup button, I get an error message like this:

NSCannotCreateScriptCommandError (10)

The code I am using is this:


tell window "EditRunData"
	set myData to item theID of _tracking
	[...]
	// this is the problem line
	set current menu item of popup button "inp2" to menu item of it whose title is (item 2 of myData as Unicode text)
	[...]
end tell

Any help with this is appreciated.

Thanks,
Andrew

Model: iBook G4 1GHz
Browser: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.7.8) Gecko/20050427 Camino/0.8.4
Operating System: Mac OS X (10.3.9)

Appear to have solved my own problem, here’s my fixed code:

set myMI to name of some menu item of popup button "inp2" whose title is (item 2 of myData)
tell popup button "inp2"
	set current menu item to menu item myMI
end tell

:rolleyes:

Thank you so much andytheweirdo !!!
I was searching for this for such a long time !!

GREAT

Somewhat less verbose, you could also say:

set myMI to title of current menu item of popup button “inp2”

Regards,
-r