Subj : Re: Stuck on the basics - HELP! To : netscape.public.mozilla.jseng From : "Stu" Date : Thu May 22 2003 02:39 pm "Georg Maaß" wrote in message news:baifd3$2tt$2@ID-3551.news.dfncis.de... > Stu wrote: > > > Hi, > > I'm trying to call a Javascript function from C/ C++ with the Spidermonkey > > API > > I've verified that I can call a basic script with a script of var hi = > > "hello"; hi.toString(); > > This script successfully return "hello" with EvaluateScript, or > > CompileScript and ExecuteScript > > However once I put it inside a JavaScript style function i.e function > > Hello() {var hi = "hello"; hi.toString();} > > I then try to use JS_CompileFunction which Compiles OK and then > > JS_CallFunction which returns successfully but gives me an "Undefined" > > string back via rval. > > > > The function Hello does not return a value, so calling it results in a > undefined (not existing return value. > > Hello(){return 'hello';} > > This should work as desired. > yes is does its just wrapped over the line. I've just verified anyway by changing the code to > Hello(){return 'hello';} but that gives the same return 'undefined' Any other ideas, could it be the way I'm reading back the return value? cheers, Stu .