Solved

Pascal equivalent of VB Select/case

Posted on 2014-01-20
3
330 Views
Last Modified: 2014-01-20
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.
0
Comment
Question by:etiennedemers
  • 2
3 Comments
 

Author Comment

by:etiennedemers
Comment Utility
I try the Case command but I get Error E2001: Ordinal type required and its a string I want to use...
0
 
LVL 34

Accepted Solution

by:
Dan Craciun earned 500 total points
Comment Utility
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
 

Author Closing Comment

by:etiennedemers
Comment Utility
Thank you Dan.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now