"get current menu item of popup button" problem

I did search the forum extensively but can’t find a solution. If it is there, please point me to it and I’m sorry.

I have a translated application in which I work with localized strings also for popup buttons.

I have no problem retrieving something like (whether or not with a localized string):

if (title of current menu item of popup button "whatever") = "something"

I also save some text and checkbox states between sessions which makes it easier for the end user.
Now I also want to save the state of one of the popup buttons which is populated with a localized string. In this case I don’t want to save the localized string, I want to save the index. This in case the user changes languages between sessions (strange, I know, but just in case)

I can do:

set SomeVariable to current menu item of popup button "whatever"

But then what is this SomeVariable for kind of variable?
If I do something like:

display dialog "my variable is " & SomeVariable

I get an error message that it can’t be converted to text. I tried conversions like “as Unicode text”, “as integer”, etc.

Hi,

current menu item is of class menu item,
this means, your variable holds a reference to this UI element

Ok, thanks for your answer. That makes sense.

But then how do I get the index?

I can do:

set menu item 1 of popup button 1 to "first entry"
set menu item 2 of popup button 1 to "second entry"

But how to get the index of the current menu item?

So that I can write it to preferences and read it back to make it possible to set the default back to something like
“set current item of popup button 1 to menu item ”

you can identify a menu item by name (title) or by tag.
You can set tags programmatically or in Interface Builder

Ok, I will have a look at tags. I never used them.

My popup is generated based on a per language array containing (translated) strings. In the worst case scenario I will save language and localized string on program end. On program start the language and string will be retrieved again.
If the language has been changed (might never happen), the “current menu item” will be set to the correct string in the new language based on it’s array index, not on menu index.

Thanks for your replies.