String , switch case, 200 conditions compare

I have almost 200 different string inputs coming from Serial Port to which i want to compare each of them and then perform 200 different task at each conditions ,
I know Switch Case is the way to go but the Strings with switch case do not works ,I have read all forums but nothing so far, So any other better suggestions ,

So any other better suggestions ,

Don't use Strings.

(deleted)

vinayharne:
I have almost 200 different string inputs coming from Serial Port to which i want to compare each of them and then perform 200 different task at each conditions ,
I know Switch Case is the way to go but the Strings with switch case do not works ,I have read all forums but nothing so far, So any other better suggestions ,

Sure. Make sure all the strings you are comparing to are the same length. Pad with spaces at the end if necessary.

Put the strings in an array and write code to compare each entry to the string in the serial buffer. Let your index number for the matching string become your Switch case driving number. Or make a second array of pointers to the 200 different functions and use the matching index to select the pointer you desire.

Probably other ways.

Paul

I'd try to make unique hash codes from the strings. Then hash the received message and switch depending on the hash value.

DrDiettrich:
I'd try to make unique hash codes from the strings. Then hash the received message and switch depending on the hash value.

With 200 cases?

I would go with Paul_KD7HB's solution with function pointers; preferably in a struct. And a hash can be a nice space saver in there :wink:

use lexical analysis

Mark

By the way if the count really is 200 hundred then you have got something wrong.

Mark

holmes4:
By the way if the count really is 200 hundred then you have got something wrong.

Mark

?

I'm not sure what @holmes4 had in mind - except that he might have been thinking along the same lines as me.

What on earth could give rise to 200 choices? There must be a better way. For example if there were 10 groups of 20 there would only be 30 choices.

@vinayharne, you need to tell us what this is all about and give some examples of the messages being sent to the Arduino.

...R

This screams XY problem.

I could imagine 200 different error messages from some program or device. As long as the TO does not disclose further informations, the thread/problem can be considered resolved.