Subj : Re: Sending Parameter (argc, argv) to a java script. To : netscape.public.mozilla.jseng From : Sterling Bates Date : Wed May 26 2004 01:02 pm Laurent Marzullo wrote: > Hello, > > I've got an Array of jsval in a C++ application, I create a > JSObject* with JS_NewArrayObject( ... ); > > I then want to execute a JavaScript file and to pass the array created > above to the script. (as argc, argv parameter of a C main function) ? > > What is the step with the spidermonkey JS API to export the Array with > the name 'argv' to a javascript ? (Or any other way to be able to refer > to this array in the javascript file). If I understand what you're saying, there are two ways: 1. Define the array as a global array object: JS_DefineProperty(cx, global, "myarray", OBJECT_TO_JSVAL(myarray), nil, nil, 0); (To define the array as a property of any other object, simply replace global with another JSObject instance.) 2. You could pass the array as a parameter to a js function: JS_CallFunctionName(cx, global, "myfunc", 1, OBJECT_TO_JSVAL(myarray), @rval); Does that answer your question? Sterling .