One of the things in Delphi that frustrates me is the inability to match on strings in case statements. For those people who haven’t done delphi before, case statements are very similar to c++ switch statements, and only opererate on ordinal types.. Now I’ve not done any Java, but as I understand it you can’t switch on strings in that language either. You can in c# though.
I think C# is generally better, but that said I have it on good authority that templates are still much better in C++ than generics are in C#.
Anyway, that’s enough rambling. On to the solution.
What you need to do in order to get around this limitation is cheat. Well, it’s not really cheating. The tricks is to use a look up function that accepts a string, one that you are expecting, which you have in a string array. Then all you need do is return which element of the array has been matched, and use that in the case statement.
See! That’s how simple it is.
Maybe in a future version of delphi borland/codegear will introduce native string support for case statements. I won’t hold my breather though.