On Sat, 21 Mar 2009, Lee Jenkins wrote:
> 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? In the case of strings, it would mostly be code readability. For ordinal types, a case statement can be optimized using jump tables. Michael. _______________________________________________ Lazarus mailing list [email protected] http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
