Subj : Re: How to call one JavaScript's method in another JavaScript To : mozilla-jseng@mozilla.org From : tomi@osaka.niss.co.jp (Tomita Tomohiro) Date : Thu Feb 13 2003 02:48 am Hi. On 10 Feb 2003 01:54:56 -0800 s_anupriya@sify.com (Anupriya) wrote: > Hi All! > > I'm very new to Rhino scripting engine. We are using the Rhino > scripting engine that do the compilation and run the scripts. > > Actually I want to define my few constants or methods in one java > script file and want to call them from another java script file lying > in the same directory. > > Please tell how it's possible??? The answer is possible. You can treat scripts as parent and child. see http://www.mozilla.org/rhino/scopes.html #I usually use ImporterTopLevel as a top level parent. #because that implements importPackage(),importClass() method. #It's useful. Define constant variables or functions in parent scope, you can make child scriptableObject as follows. in a certain method: Context cx = Context.enter(); Scriptable parent = new ImporterTopLevel(cx); : in a other method: Context cx = Context.enter(); Scriptable scope=cx.initStandardObject(parent); the first cx and second cx is same object until their method is in the same thread. Regards Tomohiro. > > Thanks > Anupriya .