[Lazarus] Easiest way to "case" strings

Lee Jenkins lee at datatrakpos.com
Sat Mar 21 15:28:20 CET 2009


Vincent Snijders wrote:
> Reenen Laurie schreef:
>> 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?
>>
> 
> You can use stringcase:
> http://lazarus-ccr.sourceforge.net/docs/lcl/lclproc/stringcase.html
> 
> Unfortunately without example. It is used in the Lazarus sources, so 
> maybe you find out how to use it from there.
> 
> Vincent

Can anyone say why there is no string case statement in Object Pascal?  I've 
always wondered about this as sometimes it hard to avoid 10-20 If..then..else 
if.... statements.

Would the compiled code of a string case statement even be any more efficient or 
is the benefit mostly in code readability?

--
Warm Regards,

Lee



More information about the Lazarus mailing list