Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How can I call a handler in another script



I have several script files in my ASS project. At least one of those
files contains handlers that need to be called from other script files.
How can I do this?

In my mind, when the ASS project launches, it already loads my central script into memory. It seems inefficient to the point of incompetence for my program to reload it into memory each time I need it.

A somewhat late response:

I appreciate your input, Harald, so thanks for taking the time. This has been an as yet unresolved problem for me.


Declare the loaded script as global. Then, in the other scripts (also loaded into the main script) declare their needs as global. This way, it is easy to conveniently and efficiently "share" loaded handlers in several scripts, making the whole thing very modular. The important trick is that one script must act as a "main" or "top level" script that loads the others that need common access to things.

But, doesn't that mean that instead of loading the shared libraries repeqatedly, once for each script file, we change the inefficiency to instead load all script files (except the "main" one) twice into memory?


ie:

By using "load script" in each or the n scripts that need the libraries, we load each library script into memory n times (but it's only needed once).

or

By using "global... load script" in a main script to load each of the script files, (which are likely to be quite large), ASS loads each one twice: once into memory in its own file, and once when the load script command in the main file is executed.

I just can't believe how inelegant and inefficient ASS seems to be at having one script call another. Surely one of the main points of having modularized script files is to be able to centralize resources and call them from multiple points.

Thanks,
Tom
T&B

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-studio mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/applescript-studio/email@hidden

This email sent to email@hidden
References: 
 >Re: How can I call a handler in another script (From: Paul Berkowitz <email@hidden>)
 >Re: How can I call a handler in another script (From: T&B <email@hidden>)
 >Re: How can I call a handler in another script (From: Harald E Brandt <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.