Pascal equivalent of VB Select/case

Hi Experts,

its been a while since I have used Delphi and I feel silly for asking such a basic question but how the heck do you do a simple select case?

I have a function that returns a string and want to do something depening of the value:

IE

Select myString Case

'A': do this
'B': do that
else: do something else

end;

Thanks,
E.
etiennedemersAsked:
Who is Participating?
 
Dan CraciunConnect With a Mentor IT ConsultantCommented:
Case only works with ordinals. But you can trick it using IndexStr. Something like

Case IndexStr (myString, ("A", "B")) of
  0: code; //A
  1: code; //B
  else: code;
end.

HTH,
Dan
0
 
etiennedemersAuthor Commented:
I try the Case command but I get Error E2001: Ordinal type required and its a string I want to use...
0
 
etiennedemersAuthor Commented:
Thank you Dan.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.