Macromedia dreamweaver 8-extending dreamweaver Manuel D’Utilisation

Page de 504
The C-level API
469
JSBool JS_ExecuteScript()
Description
This function compiles and executes a JavaScript string. If the script generates a return value, 
it returns in 
*rval
.
Arguments
JSContext *cx
JSObject *obj
char *script
unsigned int sz
jsval *rval
The 
cx
 argument is the opaque 
JSContext
 pointer that passes to the JavaScript function.
The 
obj
 argument is a pointer to the object in whose context the script executes. While 
the script is running, the 
this
 keyword is equal to this object. Usually this is the 
JSObject
 pointer that passes to the JavaScript function.
The 
script
 argument is a string that contains JavaScript code. If the string size is not 
specified (see the 
sz
 argument), the string must be null-terminated. 
The 
sz
 argument is the size of the string, in bytes. If sz is 0, the length of the null-
terminated string is computed automatically. 
The 
rval
 argument is a pointer to a single 
jsval
 structure. The function’s return value is 
stored in 
*rval
.
Returns
A Boolean value: 
JS_TRUE
 indicates success; 
JS_FALSE
 indicates failure.
JSBool JS_ReportError()
Description
This function describes the reason for a script error. Call this function before returning the 
value 
JS_FALSE 
for a script error to give the user information about why the script failed (for 
example, “wrong number of arguments”). 
Arguments
JSContext *cx
char *error
size_t sz
The 
cx
 argument is the opaque 
JSContext
 pointer that passes to the JavaScript function.
The 
error
 argument is a string that contains the error message. The string is copied, so 
the caller should free the string when it is not needed. If the string size is not specified (see 
the 
sz
 argument), the string must be null-terminated. 
The 
sz
 argument is the size of the string, in bytes. If sz is 0, the length of the null-
terminated string is computed automatically.