Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!lll-winken!taco!garfield.catt.ncsu.edu!eagle From: eagle@garfield.catt.ncsu.edu (Daniel L'Hommedieu) Newsgroups: comp.lang.pascal Subject: Re: case (string) of Message-ID: <1991Jun4.012145.8522@ncsu.edu> Date: 4 Jun 91 01:21:45 GMT References: <1991Jun3.222059.16125@javelin.sim.es.com> Sender: news@ncsu.edu (USENET News System) Organization: North Carolina State University Lines: 30 tpehrson@javelin.sim.es.com (Tim Clinkenpeel) writes: >so i can't use case for strings, eh? what are my alternatives? a list of >if-thens? (tp5.0) I liked to use a single string of all of the possibilities, evenly spaced. That way, you can divide by the width of each entry (the same for all) to then use a case. For example (please forgive if I use "C" grammar, because that's my primary language now): var possible,test:string; found:integer; begin possible="DIR CLS SET MATCH"; { notice that all are 5 wide! } test="SET"; found=(pos(test,possible)/5); if (found<>0) then case found of 1: begin /*perform stuff for DIR here*/ end; 2: begin /*perform stuff for CLS here*/ end; .... you get the picture, no doubt. Daniel L'Hommedieu eagle@catt.ncsu.edu -- As the sweat poured down my forehead, I quickly glanced at the clock to see how much longer I had to complete my exam. The two hours left would seem like days. As each precious second passed, I decided I should make up new math rules. Two hours is enough to be creative, isn't it?