Cabbage Logo
Back to Cabbage Site

Set multiple identifiers with one cabbageSet?


I’m wondering if there’s any way to set multiple widgets identifier-value with one line?

Right now I’m doing this, which works fine.

cabbageSet 1, "PitchGainDot", sprintfk("visible(%d) ", 0) 
cabbageSet 1, "PitchGainLine", sprintfk("visible(%d) ", 0) 
cabbageSet 1, "PitchGainBgr", sprintfk("visible(%d) ", 0)    

But if I have a ton of widgets, then it would make the code alot cleaner to set the visible() identifier to 0 for all these widgets with a single line. Is this possible?.. maybe with arrays?

If I remember correctly, just create a string in your sprintfk statement that includes multiple identifiers should do the trick. I would think it would be faster to break them up into multiple calls, but probably not by much.

Sorry, I think my explanation was a little bad. I was thinking of something like this:

cabbageSet 1, ("PitchGainDot", "PitchGainLine","PitchGainBgr") , sprintfk("visible(%d) ", 0)

Setting the visible-identifier to 0 for 3 different widgets with one line.

No, but that’s where cabbageGetWidgetChannels name is a real time saver. Just grab an array of the channels you need to set them in a loop. In pseudo code:

SChannel cabbageGetWidgetChannels "_group(\"pitchSliders\")"
kCnt = 0
while kCnt < lenarray(SChannel) do
   cabbageSet 1, SCHannel[kCnt], sprintfk("visible(%d) ", 0)
   kCnt +=1

Of course you also have the option of putting these into a plant and making that invisible…

1 Like

That’s useful, thanks!

You need to add _group("pitchSliders") to each slider. This is a simple way of marking them unique from other sliders.

This group identifier works with all widgets or only sliders?

It’s actually a user defined identifier, and can be applied to any widget. I’ve been using them to group different parameters together. I’m using multiple instances of the same instrument, and I use “_tag("oscX")” with “X” being a unique number for each. You can use any string following the “_” to create your own identifier.

1 Like
1 Like