switch...case problem
yan_benyamin
Posts: 42
Hello, again. Look at this code below. With this code, I can do Treble Up, not down. If I put treble down before treble up, it can't do treble up. Any idea why? btw, I get the 'Treble Down' and 'Treble Up' string on telnet.
if ([activezone,nSetTreble]) { switch(button.input.channel) { case nTrebDn: { send_string 0,'Treble Down' if (activetreble > 1 ) { activetreble = activetreble - 1 } else { activetreble = 1 } } case nTrebUp: { send_string 0,'Treble Up' if (activetreble < 20 ) { activetreble = activetreble + 1 } else { activetreble = 20 } } send_string dvDAS,"'MSTR',itoa(get_last(ndvkp)),',',itoa(activetreble),10" send_level ndvkp[get_last(ndvkp)],1,(activetreble*255)/20 } }
0
Comments
Ken . . . the compiler is looking for another CASE, not a SEND_STRING or SEND_LEVEL. Those two things are in the SWITCH.
My question on the example code is what is the value of nTrebDn and nTrebUp? are these constants? are they variables being set somewhere? If the values at the time of the execution of the S/C are the same then the one on the top of the heap will execute alwasys and then the S/C terminates.
action in a switch not in a case = bad
This compiles and works! Look mom no braces!
This one is out of the topic. What should I use the MET-6 buttons for, if I'm using it to control Matrix Audio? The 6 buttons I assume are for source selections. What's the center button for? Is it logical to use it for muting?
Correct, they are only required if you need to declare variables inside the CASE.
I use the center button as a mute, turning on the LED when mute is active.
That seems creepy to me. It just looks wrong.