Subj : Re: spidermonkey cross script execute doesn't work To : netscape.public.mozilla.jseng From : Mike Moening Date : Wed Mar 16 2005 01:23 pm Thanks for your reply! To recap my understanding: Basically the JS_CompileScript generates the bytecode but nothing else. (Allows for multiple execute calls) The JSEvaluateScript actually "runs" the script. So in the case of the 1st script I have to be a little carefull not to add any javascript code that would actually execute other than declaring functions which would be called by the second script. One followup question. Is it necessary to "Root" the compiled scripts to protect them from GC? I'm not really clear on how this actually works. I store my compiled JS_Script pointers an a for later reference. Are they safe? I'm in a multi-threaded environment. This thing is really cool. Again, thanks for the reply! "Brendan Eich" wrote in message news:423880C1.6090306@meer.net... > Mike Moening wrote: > > I compile two scripts using JS_CompileScript(). > > The second script uses a function compiled by the first script. > > I call JS_ExecuteScript() on the second script and get the error "function > > is not defined". > > How can I load multiple scripts into the context and allow one to call > > functions defined in a different compiled script? > > > You must call JS_EvaluateScript, or JS_CompileScript + JS_ExecuteScript, > in turn, for each script in sequence. > > Compiling doesn't define function or variable names in the global object > you pass when executing. > > Evaluate == Compile + Execute, btw -- it's just a shorthand API. > > /be .