Search the web
Sign In
New User? Sign Up
jsosa · JavaScript OSA-Talk
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Want your group to be featured on the Yahoo! Groups website? Add a group photo to Flickr.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Hello!   Message List  
Reply | Forward Message #493 of 529 |
Re: [jsosa] Hello!

> 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




Mon Jan 2, 2006 3:00 am

admiralnovia
Offline Offline
Send Email Send Email

Forward
Message #493 of 529 |
Expand Messages Author Sort by Date

I'm a Javascript programmer, doing much of my coding at work in a Windows Script Host environment, writing scripts to accomplish various repetitive tasks. I...
Spade Aceman
spadeaceman
Online Now Send Email
Dec 30, 2005
6:24 am

... 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...
arthur@...
admiralnovia
Offline Send Email
Jan 2, 2006
3:00 am
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help