Calling a function using a variable

My code currently receives a OSC value into a variable and I'd like to call a function using that variable. For example, the osc message looks like this:

/dmx/set and a value of say 0.5

The variable is set to the second part of the address 'set'. I now want to call the set() function and pass on the value of 0.5. How would I do this? I thought about using case switch, but it won't allow you to switch on a string type variable. Is there any way to do this?

You could use strcmp to match the function name from an array of names, then use the index in the switch statement. If all the functions were of the same type, you could use a structure containing the name of the function, and a pointer to the function itself, when you get a match, you call the function via the pointer. Lots of ways.

but I'd rather not have to go through several if statements to find the one match

You've got to find it some way or another - how many options have you got?

Could you select it as you receive each character of the function name?

binary chop?

Can you explain the problem a bit more?

Hmm sounds like it may work. This is what I got so far:

void loop() {
  //Is an OSC message available?
  if ( osc.available() ) {
    //this will be our variable that we want to call as a function. Possible values may be 'set' 'flash' 'tap' etc
    char *var = recMes.getAddress(1);
    //this is the value that we need to pass to the function
    float value = (float)recMes.getArgFloat(0);

   //How do I call the right function here????

void set(float value){
//do something

void flash(float value){
//do something

void tap(float value){
//do something

Sorry still a little new to some of these concepts. Thanks again!

Sorry about the previous post I removed. Realised I'd be better off explaining it a bit more. Thanks.

Something like:

typedef struct {
  char* fnName;
  void (*fn)(float val);
} myFns;

myFns allMine [] = { {"set", set},
                               {"flash", flash},  
                               {"tap", tap}};

Great I'll give it a try. Thanks heaps!