How to use a String Variable as Function Name?

Hi,

does anybody know how to use a string as a function name? I want to avoid a lot if switch or if-else chains and therefore directly "build" the name of a function according to the DoPrompt-String.
For example, if you type the following in the command line everything works well:

Function Test_Function(a)
       Variable a
      return a
End

// type the following also in the command line:

 String ab = "Test_Function"
 print $ab(2)


If I use the same concept inside a function Igor tells me "can't use $ inside a function in this way". Is there any possibility for this?

Thanks a lot
You can do it using the Execute operation to execute the command.

A better way is to use FUNCREFs. For example:

Function FProto()
    Print "FProto called"
End

Function F1()
    Print "This is F1"
End

Function F2()
    Print "This is F2"
End

Function Test(val)
    Variable val            // 1 or 2
   
    String functionName
    sprintf functionName, "F%d", val
   
    FUNCREF FProto f = $functionName
    f()
End