switch...case problem
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
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 }switch (i) { case 1: { //do something } case 2: { //do something else } send_string 0, 'Oops, no statements should be here relative to the curly braces!' }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
if (1) { switch(curr_button) { case nTrebUp: send_string 0,'Treble Down' if (activetreble > 1 ) activetreble = activetreble - 1 else activetreble = 1 send_string 0,'see if this works1' case nTrebDn: send_string 0,'Treble Up' if (activetreble < 20 ) activetreble = activetreble + 1 else activetreble = 20 send_string 0,'see if this works2' } //send_string dvDAS,"'MSTR',itoa(get_last(ndvkp)),',',itoa(activetreble),10" //send_level ndvkp[get_last(ndvkp)],1,(activetreble*255)/20 }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.