Page 1 of 1

CASE min TO max

Posted: Tue Feb 23, 2021 2:51 pm
by Electroguard
If you take the time and effort to implement something CiccioCB, it obviously offers some worthwhile benefit even if that benefit is not immediately obvious to me... as with the additional CASE min TO max option.
Annex Help mentions the syntax, but doesn't explain how to use it, or give any usage limitations or constraints.
(eg: can it only be consecutive integers from min to max?)

It's just that I noticed it mentioned twice in the Change Log - "Implemented CASE min TO max" (Version 1.41 beta 3 and Version 1.39 beta 9) - and if you can be bothered to implement it, the best way to appreciate that is to know how to use it... so could you explain how to benefit from using CASE min TO max please ?

Re: CASE min TO max

Posted: Tue Feb 23, 2021 3:02 pm
by bugs
I requested this (back in December 2019) for this sort of use:-

Select case temperature
case 0 to 10 : tempcolour=blue
case 11 to 19: tempcolour=yellow
etc...
End select

Re: CASE min TO max

Posted: Tue Feb 23, 2021 3:32 pm
by Electroguard
Ah ok, so is used for groups of numbers, therefore presumably min and max need to be numeric.

Re: CASE min TO max

Posted: Tue Feb 23, 2021 4:55 pm
by PeterN
I was happy to be able to use that in my CO2-Traffic-Light code:

Code: [Local Link Removed for Guests]

'######################################################################
SET_CO2_TRAFFIC_LIGHT:

SELECT CASE eCO2
    
  CASE 300 to 500 :    'GREEN range
    PIN(LED_GREEN)  = 1 - PIN(LED_GREEN)
    PIN(LED_RED)    = 0
    PIN(LED_YELLOW) = 0
    
  CASE 501 to 700  :  'YELLOW range
    PIN(LED_YELLOW)  = 1 - PIN(LED_YELLOW)
    PIN(LED_RED)    = 0
    PIN(LED_GREEN) = 0

  CASE 701 to 9999 : 'RED range
    PIN(LED_RED)  = 0
    pause 200
    PIN(LED_RED)  = 1 - PIN(LED_RED)
    PIN(LED_GREEN)  = 0
    PIN(LED_YELLOW) = 0

  CASE ELSE:
    PIN(LED_RED)    = 1
    PIN(LED_YELLOW) = 1
    PIN(LED_GREEN)  = 1
END SELECT
return

'######################################################################

Re: CASE min TO max

Posted: Tue Feb 23, 2021 5:24 pm
by Electroguard
Thanks Peter, that it a clear example of usage.

Re: CASE min TO max

Posted: Wed Feb 24, 2021 10:10 am
by cicciocb
Just for info, there is a little example in the documentation
[Local Link Removed for Guests]

Code: [Local Link Removed for Guests]

CASE 7 TO 10 : PRINT "case 7 to 10"