We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
eval statement? (Read 1240 times)
eval statement?
May 3rd, 2005, 4:15pm
 
Another simple question (I hope)..

Is it possible to do the following (with a different syntax, as this one doesn't work!)

String func = "myFunc";

void myFunc(){
 ...
}

eval(func + "()");

basically to have a function name as a string and use that string to call the function.

in Actionscript:
this[func]();

Or do I have to create a case/if statement to call each function explicitly.

Thanks
Guy
Re: eval statement?
Reply #1 - May 3rd, 2005, 5:19pm
 
You can't do that sort of thing with Processing, you'll have to write some if/switch/whatever code to chose which function to run.
Re: eval statement?
Reply #2 - May 3rd, 2005, 5:26pm
 
some previous threads on this one from the old board:
http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_Software;action=display;num=1079959163
http://processing.org/discourse/yabb/YaBB.cgi?board=Programs;action=display;num=1109184302
Page Index Toggle Pages: 1