I have wanted such a thing in the past when doing quick & dirty apps but I
guess from a strict computer science POV, that it is not a good idea to do a
case select on a string - its not efficient & matching strings gets dodgy if
you need to consider case & spaces etc.
My approach is to drop the strings & use a enum type...ie:
type
TResponseTypes =
(
rtHello,
rtGoodBye,
);
...
myvar : TReponseType;
case myvar of
rtHello : showHello;
rtGoodBye : showGoodBye;
else
raise some_nasty_exception;
end;
(Delphi/Object Pascal could be worse - ie the C select statement <g>).
BTW - does VB really have two key words 'select' / 'case'
-----Original Message-----
From: Jeremy Coulter [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, 15 February 2000 14:38
To: Multiple recipients of list delphi
Subject: [DUG]: VB Like Case statement
Hi all.
the one thing I DO miss from VB is its case statement which can be a number
or a string.
i.e. select case myvariable
case "Hello"
show_hello
case "goodbye"
show_goodbye
end select.
This has its good and bad points, BUT ofcourse in Delphi it pretty much has
to me an integer etc.
Does anyone have any ideas how this could be implemented in Delphi, OR if
Delphi has a simlilar type of thing....
THanks,
Jeremy Coulter (manager)
Visual Software Solutions
110 Harewood Road
Christchurch
ph +64 3 3521595
fx +64 3 3521596
cell +21 2533214
http://www.vss.co.nz <http://www.vss.co.nz/>
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz