PDA

View Full Version : Select Case syntax



keithdoxey
- 26th September 2005, 22:55
Hi All,

Had a search but cant find an example of what I am trying to do.

I am writing a program to decode various IR formats and have hit a problem with SELECT CASE.

Because the timing of the recieved signals is not exact I want to specify a window of acceptance. I tried using Select Case and although it would compile, the code did not work.

I recreated the segment using IF statements and that worked. I then readded a section of Select Case code where some of the cases are less than, some are more than, and one is a between.

I cant get the between to work. I have tried writing the statement in different ways but it wont compile. Is it possible to perform two tests in a single case ?

Extract of code shown below

If Header > 8800 AND Header < 9200 then Hserout ["NEC??",13]
If Header > 7800 AND Header < 8800 then Hserout ["Pioneer??",13]
If Header > 870 AND Header < 930 then Hserout ["RC5??",13]
If Header > 2500 AND Header < 2800 then Hserout ["RC6??",13]
If Header > 2200 AND Header < 2500 then Hserout ["Sony??",13]

Select Case Header
Case Is < 2000
Hserout ["Not Sony!",13]
Case Is > 7000
Hserout ["NEC type",13]
Case Is > 2200 AND Is < 2500
Hserout ["Sony code",13]
Case Else
Hserout ["Something else",13]
End Select

I would prefer to use Select Case if possible but if not will have to resort to multiple IF statements.

Thanks

Darrel Taylor
- 27th September 2005, 18:53
Hi Keith,

I don't know if this is any better or not, but it's another way you might try.
<font color="#0000FF"><b><i>' Type 0 1 2 3 4 5 6 7 8
</i></b></font><font color="#008000"><b>LOOKDOWN2 </b></font><b>Header</b>,&lt;[<b>870</b>,<b>930</b>,<b>2200</b>,<b>2500</b>,<b>2800</b>,<b>7800</b>,<b>8800</b>,<b>9200</b>,<b>65535</b>],<b>Type

</b><font color="#008000"><b>SELECT CASE </b></font><b>Type
</b><font color="#008000"><b>CASE </b></font><b>0</b>,<b>2</b>,<b>5</b>,<b>8 </b>: <font color="#008000"><b>HSEROUT </b></font>[<font color="#FF0000">&quot;Something else&quot;</font>,<b>13</b>]
<font color="#008000"><b>CASE </b></font><b>1 </b>: <font color="#008000"><b>HSEROUT </b></font>[<font color="#FF0000">&quot;RC5??&quot;</font>,<b>13</b>]
<font color="#008000"><b>CASE </b></font><b>3 </b>: <font color="#008000"><b>HSEROUT </b></font>[<font color="#FF0000">&quot;Sony??&quot;</font>,<b>13</b>]
<font color="#008000"><b>CASE </b></font><b>4 </b>: <font color="#008000"><b>HSEROUT </b></font>[<font color="#FF0000">&quot;RC6??&quot;</font>,<b>13</b>]
<font color="#008000"><b>CASE </b></font><b>6 </b>: <font color="#008000"><b>HSEROUT </b></font>[<font color="#FF0000">&quot;Pioneer??&quot;</font>,<b>13</b>]
<font color="#008000"><b>CASE </b></font><b>7 </b>: <font color="#008000"><b>HSEROUT </b></font>[<font color="#FF0000">&quot;NEC??&quot;</font>,<b>13</b>]
<font color="#008000"><b>END SELECT</b></font>

keithdoxey
- 27th September 2005, 19:19
Thanks Darrel,

I think I might be able to do something with Lookdown2.

Just had to lean over to the TV and MANUALLY turn the volume down. Currently surrounded by so many remote controls whilst testing that I couldnt see the one for the TV !

Regards