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.
IndexProgramming Questions & HelpIntegration › Processing Interpreter
Page Index Toggle Pages: 1
Processing Interpreter? (Read 2186 times)
Processing Interpreter?
Jun 8th, 2010, 12:08am
 
I have a Java applet which is embedded in a html page. This applet receives a Processing code string - just the methods like setup, draw ... as plain string. The code is written by people using the webpage not by myself.

Is there a way to evaluate Processing Code in runtime without compiling like an interpreter?

I have tried using ToolProvider.getSystemJavaCompiler(); to compile the code from string yet. This might work on my local machine but maybe not in an applet inside a webpage.

Re: Processing Interpreter?
Reply #1 - Jun 8th, 2010, 2:05am
 
Might be easier with Processing.js, this one is interpreted, for sure! Wink

And indeed compiling code on the fly, or even using reflection, might need the applet to be signed.
Perhaps it can be easier to use some existing interpreter, like beanShell.
Re: Processing Interpreter?
Reply #2 - Jun 8th, 2010, 4:53am
 
Thank you very much Philho,

BeanShell sounds good - I already have a BeanShell Interpreter inside my applet and this works well. I only have one big problem with the methodes of the PApplet instance.

I do the following:

frame = new JFrame( "My Frame" );
frame.setLocation(200, 200);
frame.setSize(300, 300);
applet = new PApplet();
frame.add(applet);
frame.visible = true;

This works and I get a frame with a PApplet I guess (at least I dont get any errors after importing core.jar).

I would need something like "applet.setup = mysetup" or something similar. I cannot create a dynamic class because I use BeanShell inside an applet not allowing Reflection and so no dynamic classes - just objects.

I look deeper into the JS version now - maybe this will work better.
Page Index Toggle Pages: 1