Cabbage Logo
Back to Cabbage Site

Idea: combobox values()

When using a combobox, sometimes a user might not want the entries to give contiguous values, for example I might want my entries to be “0 1 2 3” for one combobox, but “1 2 4 8” for another.

Having a values() entry that coincides with items could solve this… for example an entry could be:
combobox bounds(10, 10, 100, 40), channel(“box”), value(1), items(“One”, “Two”, “Four”), values(1,2,4)

Iain McCurdy brought this up before, but in the end we let it go. It is something that can be handled quite simply on the Csound side. Of course it depends onwhat you are trying to do. But an extra line or two of Csound code isn’t a game breaker.

I don’t know, while I agree it’s not that hard to work around, I think calling it “an extra line or two” is a bit dismissive… the prototype instrument I sent you last night would save somewhere around 30+ lines, and that’s after I put them into UDOs to make it more modular because it was used 4 times throughout the instrument, prior to that is was probably easily over a hundred. Plus I plan on adding more options to the comboboxes, so I expect that it will continue to grow.

Personally I feel there’s a lot of elegance lost in the instrument’s readability when you have to make giant stacks of if/elseif/else statements simply to juggle around which values should become which… which reminds me, I should go make some more noise about switch/case statements on the csound list too. :wink:

I’ll take a look at implementing your idea. Leave it with me.

[edit]
I’ve been thinking about my ‘adding a few lines of Csound code’ comment and you’re right. It is not accurate. In fact, you only need one line of Csound code :wink: With relation to your example earlier of items(“One”, “Two”, “Four”),

instr 1
kComboValues[] fillarray 1, 2, 4
printk, 1, kComboValues[chnget:k("combo")-1]
endin

Wouldn’t take work just a well? One of my Cabbage matras has always been why spend time hacking C++ code if Csound can do the job for us.

1 Like

Wow… I hadn’t seen your edit until now because the forums don’t notify for an edit. That’s a novel approach, I DO think that could do the trick!