Wednesday, 11 September 2013

Is there another way to do this case statement?

Is there another way to do this case statement?

I have a case statement which evaluates an integer (result of a function)
for a result code, like this:
R:= DoSomething;
case R of
0: begin
//Success
end;
-MAXINT..-1: begin
//Failure
end;
end;
If it's a failure, it returns a negative number representing an error
code. DoSomething is just any function which returns an integer as a
response code (or error code, being a negative). If it is an error, it
gets passed on to another error handler. If it's a success, it gets passed
on to a success handler (continue, etc.). Positive values will be handled
by various specific handlers.
I was wondering if there's another way to write -MAXINT..-1. Something
more along the lines of "Anything -1 and under". I tried <=-1 but the
compiler didn't like that too much.
Is there a way to do this in a case statement?

No comments:

Post a Comment