Quantcast
Channel: ClearScript
Viewing all articles
Browse latest Browse all 2297

New Post: Calling a JS Function from a script that has been exectued

$
0
0
So the issue is this, I need to load a script and execute the script, and keep it's state, for a subsequent call to a function within the script based upon a UI event.

For example:

A script:

var hello = "hello";

function spanishHello() { hello = "hola"; }
function englishHello() { hello = "hello"; }
function newyorkHello() { hello = "screw you"; }

spanishHello();

Console.WriteLine(hello);


That script is executed in the engine:

scriptEngine.Execute(script);

that works fine.

At a later point I need to call spanishHello(). It appears that the answer is scriptEngine.Invoke("spanishHello", null); but that throws a not found exception.

I suspect I'm making this harder than it needs to be. Your thoughts and suggestions?

Viewing all articles
Browse latest Browse all 2297

Latest Images

Trending Articles





Latest Images