zitsky / tiny-js

Automatically exported from code.google.com/p/tiny-js
0 stars 0 forks source link

how to call js file inside another js file? #13

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
is there any way to call one js file from inside another js file and execute 
the whole script?

thank you.

Original issue reported on code.google.com by rgray...@gmail.com on 24 Dec 2012 at 9:52

GoogleCodeExporter commented 9 years ago
To do that, you would have to write a 'native function' that took a filename, 
loaded the file into a string, and then called tiny js's execute method on it.

It is quite easy, but there are no built in filesystem access functions

Original comment by marianne...@googlemail.com on 24 Dec 2012 at 4:09

GoogleCodeExporter commented 9 years ago
thank you .. and is it going to be recursive? because 'native function' is 
going to execute first file but still there is another call inside this file ..

Original comment by rgray...@gmail.com on 24 Dec 2012 at 6:32

GoogleCodeExporter commented 9 years ago
It should be, as long as you don't do anything that isn't re-entrant in your 
function.

Original comment by Morph...@googlemail.com on 24 Dec 2012 at 10:17

GoogleCodeExporter commented 9 years ago
so the native function should be able to fread all the files including inner 
files into a big stream and execute it all at once. correct?

Original comment by rgray...@gmail.com on 24 Dec 2012 at 10:23

GoogleCodeExporter commented 9 years ago
Dear  marianne,
I just added scCmdCall function into the script.cpp file and also registered 
the native function. inside the scCmdCall function I'm parsing a test file and 
executing the buffer but unfortunately keep getting an error. 
I just attached the modified script.cpp file here. would you please take a look 
at this script and let me know what I'm doing is wrong?

-Roozbeh

Original comment by rgray...@gmail.com on 25 Dec 2012 at 8:58

Attachments: