Always executing the first CASE statement
javedwahid
Posts: 37
I'm trying to use a SWITCH statement in my code, and after running it. It looks like the first CASE statement is always executed regardless of what the value is. My Code:
SWITCH (BUTTON.INPUT.CHANNEL)
{
CASE 1: PULSE [vdvDisplay, 27]
CASE 2: PULSE [vdvDisplay, 28]
CASE 11:
{
nInputSource++
SEND_COMMAND dvDisplay, "'INPUT-',ITOA(nInputSource)"
}
}
I've noticed this happening with multiple switch statements
SWITCH (BUTTON.INPUT.CHANNEL)
{
CASE 1: PULSE [vdvDisplay, 27]
CASE 2: PULSE [vdvDisplay, 28]
CASE 11:
{
nInputSource++
SEND_COMMAND dvDisplay, "'INPUT-',ITOA(nInputSource)"
}
}
I've noticed this happening with multiple switch statements
0
Comments
BUTTON_EVENT [dvTP, 1]
BUTTON_EVENT [dvTP, 2]
BUTTON_EVENT [dvTP, 11]
{
}
or if you want some opinion on structuring your code
hopefully these help in isolating your problem. I personally prefer not to use the button.input.chanel call as I've had weird things happen with no answer as to why.
You can absolutely do what you're doing, however I usually use a function for a single, specific task that will be repeated; this way I have a single place to update a command, while many places could potentially call this function/task.
You should figure out whats causing your problem and fix it instead of jumping to an alternative means of bypassing the problem.
Regardless, I don't see anything wrong with the OP's code as posted. There is funny business taking place elsewhere.
Simply, working with the setup as the OP has setup.
You are right, there was probably nothing wrong with what the OP had;
the problem most likely lies elsewhere.
Maybe every button on the TP has channel code 1.