Button Script to "Select Next Switch"

Discuss Lemur and share techniques.
Post Reply
SBPBK
Newbie
Posts: 19
Joined: 20 May 2012 04:34

Button Script to "Select Next Switch"

Post by SBPBK »

Hi,

I am trying to script a button to select the next switch of a Switches object.

Under the Switches object, I am using this script:

ON EXPRESSION: Button.x is greater than 0
firstof(x=Switches.x +1);

I realize my math is off because upon button execution it selects ALL of the switches. Do I need to use a fraction rather than a 1? Not exactly sure about the theory behind the math for this instance, any help or clarification with this would be much appreciated!

Cheers
Phil999
Regular
Posts: 919
Joined: 11 Jan 2012 01:53

Re: Button Script to "Select Next Switch"

Post by Phil999 »

I would do it like that, maybe there's a simpler solution:

Code: Select all

decl n=firstof(Switches.x);//get the current position

Switches.x=fill(Switches.x,0,sizeof(Switches.x)); //reset

Switches.x=replace(Switches.x,1,n+1);//set the next position
Formant+Eurorack, PPG wave 2.2, Korg MS-20, etc., EWI 4000s, QuNeo, etc., Mixbus32c, u-he, MadronaLabs, Samplemodeling, NI, etc., iPad2/4/Pro
SBPBK
Newbie
Posts: 19
Joined: 20 May 2012 04:34

Re: Button Script to "Select Next Switch"

Post by SBPBK »

Works beautifully!

Phil999, I really appreciate your help! You have helped me by responding to several of my posts and I've also read your responses to questions of mine that I've had that were already asked/answer on the forum. A big thanks to you and the rest of this amazing Lemur community. :mrgreen:

Cheers
Post Reply