Forums > MaxMSP

Invoke other javascript files from inside javascript

September 30, 2009 | 10:37 am

Hi

I’d like to create a library of functions/objects inside JS which I can re-use whereever I want in my other Scripts.
I know there is no easy #inlcude "aLibFile.js" command from inside js, but perhaps Max is providing another solution for that?
In HTML and PHP you can easyily include other js-files.

Thanks for your help in advance


September 30, 2009 | 1:32 pm

Hi

I found a way:

globalfunction = function a () {
post("globalfunctionn");
}

this you can put into your lib.js.
load the lib.js somewhere and call this function inside aother js like
a();
and it works.

but still: including js-files would be more appreciative.


September 30, 2009 | 4:48 pm

JavaScript doesn’t have anything like the include’s C or the require in ruby for instance. If you put some files in the js-etensions folder though you are kinda able to emulate that behavior. Note that you’ll have to restart Max each time you change the files in there. There are a few examples included in the standard distribution, ejies does that as well if you need more examples.

BTW, there’s a dedicated JS forum Wink


September 30, 2009 | 4:55 pm

thanks for the help

I know there are zounds of boards, but I was hoping Max included something for this case in it’s js-framework which I have overseen.


Viewing 4 posts - 1 through 4 (of 4 total)