> I couldn't find any way of loading script files that's
> analogous to the way they're loaded in web pages. The
> Core.load() function seems to load each separate script
> file as its own object, which, while an excellent idea,
> doesn't mesh well with how script files are loaded in
> all the other environments.
> Is there another way of loading script files in JSOSA,
> in the same inline fashion as web browsers do?
Not built-in, but you can read in a source file and eval()
it, which gives you the same thing, ie: the source file is
evaluated in the same context as the main script:
// text file 'jslib.js'
//
function DoSomething() {
MacOS.message( 'Hello World' );
}
// main script file:
//
function Include( sourcePath ) {
var fileSpec = new MacOS.FileSpec( sourcePath );
var sourceCode = MacOS.appSelf().read( fileSpec );
return this.eval( sourceCode ); // 'this' needed for top-level context
}
Include( MacOS.homeFolder.path + '/jslib.js' );
DoSomething();
-- Arthur