On Wed, Nov 26, 2008 at 10:43 AM, <[EMAIL PROTECTED]> wrote: > Is there any easy way to include multiple files such that they can use > each others functions? > > It might seem simple, but I haven't been able > to find anything through searching...
As far as I know, there isn't anything in Rhino directly for this because each host may want to do this a different way. A loading mechanism is generally one of the first things a host environment has to add to the global object so that one bit of executing JavaScript can include other files. Various hosts will include that JavaScript various different ways. Some hosts evaluate the code of the included file in the global scope. Some hosts evaluate each file in it's own scope (with a shared global scope as the file scope's prototype.) http://www.mozilla.org/rhino/scopes.html There are some Context methods that help like compileString and compileReader. http://www.mozilla.org/rhino/apidocs/org/mozilla/javascript/Context.html The rhino shell has a "load" function and you could look at the source of that. Here is the doc http://www.mozilla.org/rhino/shell.html Here is how I let one file include another where everything is evaluated in the same global scope (like a browser does). http://code.michaux.ca/trac/browser/trunk/xjs/core/src/ca/michaux/xjs/Shell.java Peter _______________________________________________ dev-tech-js-engine-rhino mailing list [email protected] https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino
