As
Red_prig stated, a case statement only supports comparisons against constants with the exception of strings.
However, there is a way to "synthesize" an inline case statement that works with variables by doing something like this:
for LoopVar := 1 to 1 do { or "for i := i to i do" but only if "i" doesn't change in the "case" statement }
begin
{ first "case" }
if i = ib then
begin
{ do whatever is appropriate when i = ib }
break;
end;
{ second case }
if i = { some other variable } then
begin
{ do whatever is appropriate in that case }
break;
end;
{ and so on until all cases are accounted for }
end;
{ remaining function code follows the "for"/synthesized-case statement }
basically, the "for" loop is just a trick to create an inline scope to break out of. The same thing can be done using a "repeat ... until TRUE". Of course, the same thing can be accomplished by calling a function but, this way, the "case" is inline just as a normal "case" statement is.
Personally, I prefer this solution over nested "if"s which, as
howardpc stated, is the more commonly used alternative.
HTH.