Copyright © https://mongoose-os.com

Mongoose OS Forum

frame
ATTENTION! This forum has moved to:

https://community.mongoose-os.com

Do not post any new messages.

Run dynamic JavaScript code

Hi,

I want to run JavaScript code stored in a file at runtime. Something like this:
mjs.run("code.js");

What I did find so far is the "run_if_exists" method in https://github.com/mongoose-os-libs/mjs/blob/master/src/mos_mjs.c
But I cannot get a reference to the mjs object either in "main.c" neither in "init.js"

Can somebody please tell me how to achieve this?

Comments

  • quaxquax Europe

    Found a solution:
    mjs_exec_file(mgos_mjs_get_global(), "code.js", NULL);

    But how can I destroy the previous mjs instance when calling this over and over again? Especially when using Timers. They keep on running.

Sign In or Register to comment.