Subj : Re: Stuck on the basics - HELP! To : netscape.public.mozilla.jseng From : =?ISO-8859-1?Q?Georg_Maa=DF?= Date : Thu May 22 2003 03:21 pm 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. .