| Author |
switch case question
|
|
| Petterson Mikael 2004-09-23, 3:56 am |
| Hi,
Will the code below work as:" if devFaultType is equal to
RbsTypes.RBS_DEV_FAULT_GENERAL_HW_ERROR or
RbsTypes.RBS_DEV_FAULT_TOO_LOW_MAIN_LOAD or ...
RbsTypes.RBS_DEV_FAULT_TMP_SENSOR_FAULT then set result equals true?".
//M
switch(devFaultType)
{
case RbsTypes.RBS_DEV_FAULT_GENERAL_HW_ERROR:
case RbsTypes.RBS_DEV_FAULT_TOO_LOW_MAIN_LOAD:
case RbsTypes.RBS_DEV_FAULT_TOO_LOW_PRIO_LOAD:
case RbsTypes.RBS_DEV_FAULT_TOO_HIGH_MAIN_LOAD:
case RbsTypes.RBS_DEV_FAULT_TMP_SENSOR_FAULT:
result=true;
break;
default:
.....
}
| |
| VisionSet 2004-09-23, 3:56 am |
|
"Petterson Mikael" <mikael.petterson@ericsson.se> wrote in message
news:41527AF6.7060009@ericsson.se...
> Hi,
>
> Will the code below work as:" if devFaultType is equal to
> RbsTypes.RBS_DEV_FAULT_GENERAL_HW_ERROR or
> RbsTypes.RBS_DEV_FAULT_TOO_LOW_MAIN_LOAD or ...
> RbsTypes.RBS_DEV_FAULT_TMP_SENSOR_FAULT then set result equals true?".
>
> //M
>
> switch(devFaultType)
> {
> case RbsTypes.RBS_DEV_FAULT_GENERAL_HW_ERROR:
> case RbsTypes.RBS_DEV_FAULT_TOO_LOW_MAIN_LOAD:
> case RbsTypes.RBS_DEV_FAULT_TOO_LOW_PRIO_LOAD:
> case RbsTypes.RBS_DEV_FAULT_TOO_HIGH_MAIN_LOAD:
> case RbsTypes.RBS_DEV_FAULT_TMP_SENSOR_FAULT:
> result=true;
> break;
> default:
> .....
> }
It will return true for all the cases given except default.
--
Mike W
| |
| Paul Lutus 2004-09-23, 8:57 am |
| Petterson Mikael wrote:
> Hi,
>
> Will the code below work as:" if devFaultType is equal to
> RbsTypes.RBS_DEV_FAULT_GENERAL_HW_ERROR or
> RbsTypes.RBS_DEV_FAULT_TOO_LOW_MAIN_LOAD or ...
> RbsTypes.RBS_DEV_FAULT_TMP_SENSOR_FAULT then set result equals true?".
What happened when you ran your code of which this this is an uncompilable
part? How can you hold the the opinion of some Usenet posters above what
your compiler tells you? If you really want our opinion, post a short,
complete, compilable, working example.
--
Paul Lutus
http://www.arachnoid.com
| |
| Mark Haase 2004-09-23, 8:57 am |
| In article <41527AF6.7060009@ericsson.se>,
Petterson Mikael <mikael.petterson@ericsson.se> wrote:
> Hi,
>
> Will the code below work as:" if devFaultType is equal to
> RbsTypes.RBS_DEV_FAULT_GENERAL_HW_ERROR or
> RbsTypes.RBS_DEV_FAULT_TOO_LOW_MAIN_LOAD or ...
> RbsTypes.RBS_DEV_FAULT_TMP_SENSOR_FAULT then set result equals true?".
>
> //M
>
> switch(devFaultType)
> {
> case RbsTypes.RBS_DEV_FAULT_GENERAL_HW_ERROR:
> case RbsTypes.RBS_DEV_FAULT_TOO_LOW_MAIN_LOAD:
> case RbsTypes.RBS_DEV_FAULT_TOO_LOW_PRIO_LOAD:
> case RbsTypes.RBS_DEV_FAULT_TOO_HIGH_MAIN_LOAD:
> case RbsTypes.RBS_DEV_FAULT_TMP_SENSOR_FAULT:
> result=true;
> break;
> default:
> .....
> }
If those constants are primitives, it should work.
--
|\/| /| |2 |<
mehaase(at)sas(dot)upenn(dot)edu
| |
| Thomas Schodt 2004-09-23, 8:57 am |
| Petterson Mikael wrote:
> switch(devFaultType) {
> case RbsTypes.RBS_DEV_FAULT_GENERAL_HW_ERROR:
IIRC you need tiger to use final values from other classes in a
switch/case statement.
Also note that those final values are compiled into the bytecode, so if
you ever change the those final values you need to recompile all classes
that use them.
|
|
|
|