Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!mips!spool.mu.edu!uunet!ogicse!hsdndev!cmcl2!adm!news From: dm2368@eecs1.eecs.usma.edu (Fichten Mark CPT) Newsgroups: comp.lang.pascal Subject: Re: case (string) of Message-ID: <27105@adm.brl.mil> Date: 4 Jun 91 12:45:17 GMT Sender: news@adm.brl.mil Lines: 28 > From: Tim Clinkenpeel > > so i can't use case for strings, eh? what are my alternatives? a list of > if-thens? (tp5.0) > Since the 'selecter' for a case statement MUST be of an ordinal type, you can not use a string. However, there are ways around this. For example, if I have a variable called NetworkType and it is a string, and you only assign values like '3Com', 'Clarkson', 'Mine', etc., you can do a case statement like this: case NetwordType[1] of '3'{Com} : DoSomethingWith3Com; 'C'{larkson} : DoSomethingWithClarkson; 'M'{ine} : DoSomethingWithMine; end; Of course an enumerated type would work much better here but I hope that you get the idea. Hope this helps... ____________________________________________________________________________ CPT Mark Fichten | INTERNET: fichten@eecs1.eecs.usma.edu | Captain U.S. Army | @trotter.edu:dm2368@eecs1.eecs.usma.edu | | USENET: rutgers.edu!trotter!eecs1!dm2368 | | harvard.edu!trotter!eecs1!dm2368 | ____________________________________________________________________________