Subj : Returning integers from custom functions. To : netscape.public.mozilla.jseng From : "Frank Schroeder" Date : Thu Jul 17 2003 07:43 pm I've implemented a custom object with a couple of functions that are supposed to return an integer value: static JSBool Input_Width(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) { *rval=STRING_TO_JSVAL(JS_NewStringCopyZ(cx, "53")); return JS_TRUE; } When I call the function and perform an addition, Response.Write(Input.Width()+1); the result is 531, so it's concatenating the strings. Weird enough, subtraction etc. is working fine, i.e. Response.Write(Input.Width()-1); comes out as 52. What can I do to have the return value correcly treated as an integer/double and perform an integer addition? I've tried replacing the STRING_TO_JSVAL with DOUBLE_TO_JSVAL, to no avail. This is using JS 1.5 RC4a Thanks. .