Delphi case statement for integer ranges
I have a function which is being passed an integer value, representing a step value. There are 5 seperate conditions I want to test for: Value =0 Value =1 Value =-1 Value >1 Value <-1
Currently this is implemented as a set of if statements, and I would like to change this for a case statement. I have no problems with the specific value cases, or even a limited range (say 1..10) but how do i write a case representing Va开发者_运维知识库lue >1 , or Value <-1?
var
MyValue: integer;
...
case MyValue of
Low(Integer)..-2:
beep;
-1:
beep;
0:
beep;
+1:
beep;
2..High(Integer):
beep;
end;
精彩评论