Compiler error with Select Case
Posted: 20 February 2008, 5:49 AM
The compiler issues a warning for this code:
The error is
The resulting compiled code does not function correctly, the case statement evaluates true on all values.
Is there a limit to how many possible values there can be for a Case statement? The reasoning behind the single case select statement is simply a matter of readability. See this thread for more information.
-Don
Code: Select all
Select Case DataInputNumber
Case 110 OR 300 OR 600 OR 1200 OR 2400 OR _
4800 OR 9600 OR 14400 OR 19200 OR 28800 OR _
38400 OR 56000 OR 57600 OR 115200
ComBaud = DataInputNumber
End Select
The corresponding C code isRunSetup.c warning: suggest parentheses around comparison in operand of |
Code: Select all
{
int32_t _zv_selectValTemp12;
_zv_selectValTemp12 = zv_DataInputNumber;
if (_zv_selectValTemp12 == ((((((((((((110L | 300L) | 600L) | 1200L) | 2400L) | 4800L) | 9600L) | 14400L) | 19200L) | 28800L) | 38400L) | 56000L) | 57600L) | 115200L)
{
Is there a limit to how many possible values there can be for a Case statement? The reasoning behind the single case select statement is simply a matter of readability. See this thread for more information.
-Don