Cannot set a string as host object?

Feb 5, 2014 at 9:55 AM
Hi,

I may be missing something obvious, but this call fails on a V8ScriptEngine:
engine.AddHostObject("test", "hello");
Feeling like a noob... :)
Thanks for your help!
Coordinator
Feb 5, 2014 at 11:48 AM
Hello!

That's correct; ScriptEngine.AddHostObject() does not work with simple values like strings and numbers.

Instead, you can do any of the following:
engine.Script.test = "hello";
engine.Script["test"] = "hello";
engine.Execute("test = 'hello'");
Cheers!