Well, anybody that can help, here's a newbie question about GPC and regular Pascal... I know what ordinal types are, but is it possible to use a case statement with a string type, and how... I need this for a M.U.D. I'm building in Pascal, it would really help... If you wish to help me, please email me, because I'm not a member of the list...
Justin (siberdemon@aol.com) RPG Developer (on Unix ofcourse)
Siberdemon@aol.com wrote:
Well, anybody that can help, here's a newbie question about GPC and regular Pascal... I know what ordinal types are, but is it possible to use a case statement with a string type, and how... I need this for a M.U.D. I'm building in Pascal, it would really help... If you wish to help me, please email me, because I'm not a member of the list...
No, it's not possible. You'll have to use an if-then-else series which can be almost as compact as a case statement when written like this:
if s = 'foo' then ... else if s = 'bar then ... else ...
Frank
You are looking for a wrong solution!
The better solution for you is implement a hash function... After implementing it, you can do right stuff for strings!
Look for Marthin Waldenburg samples @ www.delphipages.com !
He use hash lists to syntax highlight in several components!
[]s Luiz Vaz
Luiz Vaz wrote:
You are looking for a wrong solution!
The better solution for you is implement a hash function... After implementing it, you can do right stuff for strings!
True, when the number of cases is not too small, that's more efficient. Actually, the StringUtils unit that comes with GPC contains hash routines for strings...
Frank
Yes,
It´s alright! ;-) For a few number of string items it´s not useful!
Good Said!
[]s Luiz Vaz