PDA

View Full Version : Select case...Just wondering....



muddy0409
- 29th December 2006, 15:22
I haven't tried this yet, but my reading of the manual says I should be able to do something like-----

select case X 'X is the name of a/d variable

case 0<X<20
go do something
case 21<X<40 'or should this be IS >21 AND IS < 40
go do something different
case 41<X<60
go do something different still

etc, etc.
Does anyone reckon this will work?

Just thinking out loud,
Peter Moritz.

sayzer
- 29th December 2006, 15:57
What about these?


First one works for sure.


SELECT CASE x

CASE IS < 21 'Between 0 and 20; including 20.

CASE IS > 20 AND IS < 41 'Between 21 and 40 ; including 21 and 40.

CASE IS > 40 AND IS < 61 'Between 41 and 60 ; including 41 and 60.

END SELECT



For this second one, I expect someone to confirm.




'Once it hits the first matching condition it should not go to the next one.
'Or will it?

SELECT CASE x

CASE IS < 21 'Between 0 and 20; including 20.

CASE IS < 41 'Between 21 and 40 ; including 21 and 40.

CASE IS < 61 'Between 41 and 60 ; including 41 and 60.

END SELECT

paul borgmeier
- 29th December 2006, 16:18
sayzer,
go with the second - it works the same as the first

sayzer
- 29th December 2006, 16:21
Ok, we get (save) more space then, as long as the values are in the same ascending order.

Muddy, pick the second.


---------------------------

Christopher4187
- 29th December 2006, 23:12
To further the discussion, because I have never used select case before, can you do something like this:

SELECT CASE x

CASE IS < 21 led1

CASE IS < 41 led2

END SELECT

I am used to something like this

If x=1 then
goto led1
else
goto led2
endif


Also, an OT question. How do you guys get the code to display in blue?

Thanks,

Chris

skimask
- 29th December 2006, 23:23
To further the discussion, because I have never used select case before, can you do something like this:

SELECT CASE x
CASE IS < 21 led1
CASE IS < 41 led2
END SELECT

I am used to something like this

If x=1 then
goto led1
else
goto led2
endif

Chris

Should work. If it doesn't, reverse the cases around a bit...

SELECT CASE x
CASE IS > 20
GOTO LED1
CASE IS > 0
GOTO LED2
END SELECT

Sometimes it's all about the order things go in...