How to execute a .JS file in Jurassic?

Aug 6, 2013 at 11:18 AM
Edited Aug 6, 2013 at 11:19 AM
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 :
 try
            {
                INTERNAL.OP.JavaOperation.execJS(textBox1.Text);
            }
            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));
            engine.ExecuteFile(@fname);
            return null;
        }
I made a .js script and wrote the following bunch of code :
Math.sin(3)
When I run it nothing happens, Absolutely Nothing ,
Can anybody suggest a solution for this?
Any help would be appreciated

~ALLDESP (Sids123 on CodeProject)
Coordinator
Aug 6, 2013 at 10: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).