ejSetGlobalFunction | GoAhead JavaScript API | GoAhead EMF
## Synopsis Define a JavaScript global 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, the function defined by fn 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
    char_t *emsg;

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

    ejSetGlobalFunction(int eid, "myfunc", myfunc);
## See Also JavaScript, Active Server Pages, ejOpen, ejSetVar