TName
asked on
Greater/less than... in case statement?
Hi,
My first question, so please bear with me... ;)
Does anyone know of a way to make case statements accept some construction of this kind:
case SomeInt of
<10: DoSomething;
10..1000: DoSomethingElse;
>1000 DoSomethingDifferent;
end;
Yes, I can take a very high/low value for SomeInt (higher/lower than the highest/lowest expected value), like...
case SomeInt of
-1000000..10: DoSomething;
...or even -2147483647, just to be sure :), and it will work, but it doesn't look/feel right.
BTW, I use D7 Pro.
Thanks!
My first question, so please bear with me... ;)
Does anyone know of a way to make case statements accept some construction of this kind:
case SomeInt of
<10: DoSomething;
10..1000: DoSomethingElse;
>1000 DoSomethingDifferent;
end;
Yes, I can take a very high/low value for SomeInt (higher/lower than the highest/lowest expected value), like...
case SomeInt of
-1000000..10: DoSomething;
...or even -2147483647, just to be sure :), and it will work, but it doesn't look/feel right.
BTW, I use D7 Pro.
Thanks!
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
@ geobul:
Yes, I know about if statments (frantically nesting ifs was my first passion when I started coding :), but as I hadn't explicitly ruled out this solution, your hint is valid and so I increased the points, in order to be able to split them (I hope it's ok to do it...)
@TheRealLoki :
Even if it's the same thing "under the hood", it sure is a big improvement. It definitely looks nicer than typing huge numbers.
I didn't know about maxInt (hmm, coming to think of it, I could have declared such a constant myself...).
And now I see there are many of them already declared: "MinDouble", "MaxExtended"...
Thanks!