Using one midi message to cycle through three values

Hi, I’m currently trying to make one message from my midi controller cycle through activating three different presets.

I’m thinking I just initialize a global variable as 1, and increment it every time push the button on my controller. Then to get my three states I read that variable %3 to get 1,2,0,1,2,0… and then go from there. But is this OK to do? Is there anything wrong with letting the number stored in the variable get really big? Or is there a better way to do this?

Thanks for bearing with me, I’m still a beginner when it comes to coding.

Hi, that is how you do it. Please press F1 or help to read the naming conventions for global variables in the user manual. I usuall start with “ga”. Just be careful not to go over 2,147,483,647 :wink:

All global variables are 32 bit signed integers.

Here are the rules, I would use

ga=ga+1
if ga >2 then ga=0

Steve Caldwell
Bome Customer Care


Also available for paid consulting services: bome@sniz.biz

Ohhhhhhh right. not sure why I didn’t think of just using a conditional to reset the variable. I don’t need to use modulo at all.

thanks!