This project has moved and is read-only. For the latest updates, please go here.

How to execute a .JS file in Jurassic?

Aug 6, 2013 at 12:18 PM
Edited Aug 6, 2013 at 12:19 PM
I know most of you will say "Hey Look at the Docs" and yes I have looked onto it,
But I have a little problem here :
I have a WinForms App in which there is a textbox where the users specifies the .js path and executes it by clicking a button ,
Here's the button click code :
            catch (Exception ex)
                MessageBox.Show("Dude! There's this error\n Here's the Log (if you understand)\n" + ex.Message);
Here's the code I used in the INTERNAL.OP class :
public static string execJS(string fname)
            var engine = new Jurassic.ScriptEngine();
            engine.SetGlobalValue("console", new Jurassic.Library.FirebugConsole(engine));
            return null;
I made a .js script and wrote the following bunch of code :
When I run it nothing happens, Absolutely Nothing ,
Can anybody suggest a solution for this?
Any help would be appreciated

~ALLDESP (Sids123 on CodeProject)
Aug 6, 2013 at 11:57 PM
What did you expect would happen? Math.sin(3) has no side effects, so it's not surprising you see nothing when you run that code...

If you change the code to console.log(Math.sin(3)) and then run it in a debugger, I think you'll see "0.1411200080598672" in the output window (console uses Console.WriteLine by default, which is captured by the debugger IIRC).