Subj : Re: Returning integers from custom functions. To : netscape.public.mozilla.jseng From : "Sterling Bates" Date : Thu Jul 17 2003 09:57 pm Try this: JS_NewNumberValue(cx,53,&rval); (Not sure about the & tho...) Sterling "Frank Schroeder" wrote in message news:bf7irj$spr1@ripley.netscape.com... > 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. > > > .