Re: comparison stacks
- Posted by Irv Mullins <irvm at ellijay.com> Jun 11, 2001
- 355 views
----- Original Message ----- From: Kat > > <sigh> > Ok, in the irc client, to handle the numerics from the server, the stack will > start with one "if", end with an "end if", and have *600* "elsif" in between. > Isn't that a little incredible? > I can think of several different ways to do this without the 600 elsifs... 1. Create a text file for each different server, containing lines like: 10,doSomething 145,SomethingElse 412,Stuff 593,MoreStuff Read in the file line by line, parse on the comma, and store as two arrays, {10,145,412,593....} {"doSomething","SomethingElse","Stuff","MoreStuff",...} then, when you get the numeric, do a find on array 1, and call routine_id(array2) This is good because it will be easy to write new tables (files) for different servers. 2 Create an include file containing: object v v = repeat(Null,600) -- Null should point to a 'do nothing' routine . v[10] = "doSomething" v[145] = "SomethingElse" v[412] = "Stuff" ... then call routine_id(v[numeric]) This is a little more work to write the files for different servers, and won't let you change servers during a run. 3. Look at Jiri's associative arrays. 4. Create a Euphoria database, each table being a server, and each record within that table keyed to the numeric code. That record data can contain a routine name, plus any parameters that might need to be provided. Probably the best in the longrun is #4. Regards, Irv