Hi,

I'm sure most of you have had this... is there an easy way to have a case
statement that's based on "strings" rather than ordinal types.  Is there
somewhere a shortcut?

The only solution I can think of is defining constants with strings and
ordinal types...

What I'd like to do is:
   case fruit of:
     'apple' :
     'pear' :
     'banana':
     'grape':
   else

   end;

So the only solution I can think of is
const fruitlist = (apple,pear,banana,grape);
           fruitstrings = ('apple','pear','banana','grape');

and then...

for i := apple to grape do
  if fruit {string} = fruitstrings[i] then fruitvar := i;

case fruitvar of
  apple :
  pear :
  banana :
  grape :
else
end;

Any easier solutions to trying to run a case on a "string"?

Regards,
-Reenen


-- 
o__
,_.>/ _
(_)_\(_)_______
...speed is good
_______________
I believe five out of four people have a problem with fractions.
_______________________________________________
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to