Exception when calling script include from a different script include

patrickfitz
Kilo Contributor

Hi,

encountering a sporadic error when trying to call a different script include.

var mySI = "MyOtherSciptInclude";

var k = new global[mySI]();

In my testing, the above code will work 90% of the time. When it does fail, my try/catch reports: undefined is not a function

Any insight/suggestions would be appreciated.

Patrick

5 REPLIES 5

HI Muhammad,

thanks for your response. 

The type is a string and we have been testing this over the last day or so with mixed results.

One thing I neglected to mention was that (ref my initial code snippet) the code is leveraging the JSUtil script include/getGlobal func. Looks like the latest ver of JSUtil does not include this func.

 

Thanks

Patrick

var global = JSUtil.getGlobal();

var mySI = "MyOtherSciptInclude";

var k = new global[mySI]();



** JSUtil code snippet **

/*

* Returns the Rhino global object.

*/

JSUtil.getGlobal = function(){

  return (function(){

    return this;

    }).call(null);

};