The value of the string "Func" is successfuly having a random number appended, but the function itself is not called (the delay is not executed). I cannot just execute
Func;
Can anybody help me in creating dynamically function name calls with the random number? I trying to avoid to hardcode an array with the function names like here http://arduino.cc/forum/index.php/topic,40842.0.html
Any text that isn't between quotes ("") are completely gone after the compiler runs. You need to use an array of function pointers, or something like a switch statement
Thanks for your answer. Since I don't have my hardware yet I tested your code in the Simulator and it does not work. It says "funcsrandom(4);" is an unknown command.
I have a better idea: rather than just dynamically create function names, dynamically create a compiler that compiles your dynamically created code that is dynamically flashed into a dynamically powered arduino so that it dynamically responds to inputs that are dynamically applied to dynamically assigned pins with dynamically changing frequencies and dyanmically altered amplitude.
I have a better idea: rather than just dynamically create function names, dynamically create a compiler that compiles your dynamically created code that is dynamically flashed into a dynamically powered arduino so that it dynamically responds to inputs that are dynamically applied to dynamically assigned pins with dynamically changing frequencies and dyanmically altered amplitude.
rediculum:
Can anybody help me in creating dynamically function name calls with the random number? I trying to avoid to hardcode an array with the function names like here
I don't understand why you want to avoid using an array of function pointers. It is a perfectly reasonable way to achieve what you're asking for.
An alternative, which takes more code but avoids using those scary function pointers, is to use a switch:
// uncompiled, untested
switch(random(4))
{
case 0:
func0();
break;
case 1:
func1();
break;
case 2:
func2();
break;
case 3:
func3();
break;
}