Subj : Re: Passing Variables from a function to Javscript To : netscape.public.mozilla.jseng From : "Alan Kemp" Date : Tue Mar 09 2004 02:51 pm "Zaph" wrote in message news:c982fb96.0403090514.32025d84@posting.google.com... > Hi, > > I have a C-Function that I call from Javascript with some variables. > At the End of the Function I want to pass the result back to > javascript. > > How do I do that ? > > Can anybody please help me with this ? JSBool AddThem(JSContext * context, JSObject * globalObject, unsigned int argc, jsval *argv, jsval *rval) { // error checking ommited int a = JSVAL_TO_INT(argv[0]); int b = JSVAL_TO_INT(argv[1]); *rval = INT_TO_JSVAL(a + b); return JS_TRUE; } The last parameter of your native code function is the value to be returned to the javascript caller. So just dereference the pointer you are passed, and assign it the return value (as a jsval of course). Alan .