ejSetGlobalFunction GoAhead JavaScript API GoAhead EMF

Synopsis

Binds a JavaScript function name to a C function

Prototype

#include "ej.h"

int ejSetGlobalFunction(int eid, char_t *name,
    int (*fn)(int eid, void *handle, int argc, char_t **argv));

Parameters

eid JavaScript interpreter handle
name Name of the function to define
fn C function to invoke

Description

The ejSetGlobalFunction procedure defines a JavaScript function. When the function named by name is called, from JavaScript, the function defined by fn in C is called.

When fn is called, the JavaScript parameters are passed in via argc and argv as a list of pointers to arguments. Use ejArgs to parse the arguments array.

Return Value

Returns 0 if successful. Returns -1 on errors.

Example

int myfunc(int eid, void *handle, int argc, char_t **argv);
   
ejSetGlobalFunction(int eid, "myfunc", myfunc);

See Also

JavaScript, Active Server Pages, ejOpen, ejSetVar ejArgs