Simple example fails

Sep 17, 2010 at 4:35 AM
JintEngine js = new JintEngine();
js.SetParameter("a", 1);
js.SetParameter("message""Hello world!");
var result2 = js.Run("return message + a;"); <--- error

Input string was not in a correct format.
Line: 1 Char: 0
No source code available.

I would have thought something simple like this would have worked given that it's in your examples...

In addition I was hoping that this might work, but alas, it does not.

JintEngine js;
System.Timers.Timer timer;
int counter = 0;

void StartEngine() {
    js = new JintEngine();
    js.SetParameter("console"new SystemConsole());

    // Set the event sink
    js.Run(@"function OnData(a, b){ console.WriteLine('a:' + a + ' b:' + b); }");

    // Start the event timer
    timer = new Timer();
    timer.Elapsed += new ElapsedEventHandler(timer_Elapsed);
    timer.Interval = 1000;
    timer.Enabled = true;
}

void timer_Elapsed(object sender, ElapsedEventArgs e) {
    string toRun = "OnData(" + counter.ToString() + "," + e.SignalTime.Second + ")";
    js.Run(toRun);
    counter++;
}

public class SystemConsole {
    public SystemConsole() { }
    public void WriteLine(string iString) {
        Console.WriteLine(iString);
    }
}

Comments?
Sep 19, 2010 at 5:32 PM

Hi,

I have checked both your examples and there are working fine using the current source code. Could you try again after downloading the source code ?

Thanks
Sebastien