Home Notices Documents Classes Download Others Rice
Classes  >  jsexecutor  >  Execute(string)
jsexecutor class : Execute(string) method


Executes JavaScript code passed by the argument.


jsexecutorInstance.Execute(string jsCode)


stringjsCodeJavaScript code.

Return value

int,real,string, or boolIt has stored a return value from the JavaScript code.

Sample code


jsexecutor jse = new jsexecutor();


string jsCode = "(function (){return 100;})();";


int retInt = jse.Execute(jsCode); // The retInt is 100.


The return value from JavaScript must be evaluable as the int, real, string, or bool.

If the return value from JavaScript function can not evaluate as the above classes, an empty proxy is returned.Fixed in Ver

If the return value from the JavaScript function can be evaluated as the above class, the corresponding Rice class is returned. Otherwise, the void class is returned.

Note for Ver

Escape sequences may not work properly in strings of the JavaScript code given as arguments.

Note for Ver

Above escape sequences problem is fixed.

To get the return value from JavaScript using this method, please write javascript in the form of immediate function as follows.

string oh = Execute("(function (){return 'www';}());");

An exception is raised if you give the return statement directly as follows.

string oh = Execute("return 'www';"); // Exception!

Links for reference


Copyright © Rice All rights reserved.