I created a long switch statement that one of the case conditions (the last one) is not being executed. I checked my code and the variable used in the switch statement goes to the correct type and value, but still this case statemente is begin missed.
I created another switch statemente below and it works fine now. Also, if I comment out the huge code before the last case statement, it is executed properly. What is going on?
If you declare a var inside the switch it creates a subtle bug. Clean any and all var creation within the switch and things should straighten out. That FLOAT needs to be defined OUTSIDE the switch.
There is also the distinct possibility that there is another variable of the same name with a different scope that is declared somewhere else in the code that has not been posted
The problem caused by declaring a variable inside a case statement can be avoided by either not doing it or by enclosing the code block for the case in curly braces
However, neither of those solutions will fix the potential problem of different variables with the same name and different scopes
Hi, thanks everyone for the suggestions. The solution was to remove all local variable declaration from within the case statements. The funny thing is that I had to remove them from other case statements that were indirectly affecting the execution of the last case statement. Also, there were no name conflicts anywhere in the code...