Subj : Get return value of function To : netscape.public.mozilla.jseng From : dat_nq@hotmail.com (dat_nq@hotmail.com) Date : Thu Nov 13 2003 01:55 am Hi everybody. I try to get return value of function. But I can't do that. I show my code here, anybody has a hint, please help me. Thank you very much. void JSDB::JSDB_GetReturnValueFunction(wxString function) { if(function=="") { wxMessageBox("No Script"); return; } const char * source = (const char *)function; JSBool ok = JS_FALSE; JSString * str = NULL; JSFunction * func = NULL; const char * argNames [1] = { "vartest" }; jsval argValues[1] = { INT_TO_JSVAL(10) }; char * fileName = NULL; uintN lineNum=0; jsval result; func = JS_CompileFunction(data->cxDebugger, m_jsGlobalObject, "testFunc", 1, argNames, source, strlen(source), fileName, lineNum); if (NULL == func) { return; } ok = JS_CallFunction(data->cxDebugger, m_jsGlobalObject, func, 1, argValues,&result); if (JS_TRUE == ok) { str = JS_ValueToString(data->cxDebugger, result); } else { return; } //------------------------------------ wxString ret="return value of function: "; ret += wxString::Format(" %s",JS_GetStringBytes(str)); return; } wxString temp; temp = "function testget(vartest) { var test=10; test=test*vartest; return test; }" JSDB_GetReturnValueFunction(temp); //data->cxDebugger is a context .