Symbol to value conversion?

Is there anyway, given a Symbol, to get its value? I am adding items to a menu from an array using menu.addItem(name,i) where i is the item index in to the array. But when I get the onMenuItem(item) call, item is a Symbol rather a value of 0-n. So is the anyway to take 'item' and convert it to an integer index?

I've tried using item.toString() but it just returns "Symbol" rather than a value.
  • Not that I know of. What I've done is something like this...

    const symbols = [
        :symbol0,
        :symbol1,
        :symbol2,
        :symbol3,
        :symbol4,
        :symbol5,
        :symbol6,
        :symbol7,
        :symbol8,
        :symbol9,
        :symbol10,
        :symbol11,
        :symbol12,
        :symbol13,
        :symbol14,
        :symbol15
        // only Menu.MAX_SIZE menu items allowed
    ];
    
    class MyMenu extends Ui.Menu
    {
        function initialize() {
        Menu.initialize();
    
        setTitle("test");
    
        for (var i = 0; i < 10; ++i) {
            addItem(Lang.format("Menu $1$", [ i + 1 ]), symbols[i]);
            }
        }
    }
    
    class MyMenuDelegate extends Ui.MenuInputDelegate
    {
        hidden var _values;
    
        function initialize(values) {
            MenuInputDelegate.initialize();
            _values = values;
        }
    
        function onMenuItem(item) {
    
            for (var i = 0; i < symbols.size(); ++i) {
                if (item.equals(symbols[i])) {
    
                    // use _values[i] to do something...
    
                    return true;
                }
            }
    
            return false;
        }
    }

    Travis