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



On 2004-10-05, at 01.43, T&B wrote:
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.

I'd appreciate any more help.


A somewhat late response:

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.

I wrote a mail about this topic here 2004-03-20 on the subject: "Re: Properties in multiple scripts". Check the archives. Below, I'll just paste the central paragraph:

"I have a total of 20 scripts in one project. One script will have most of the GUI handlers (but not all), it will load another script, which in turn loads a large bunch of other scripts, while also declaring them all as globals. Each script that needs access to handlers in other scripts must declare these needs as globals. So, in this way, although variables in different scripts cannot inherently be shared, the net effect is almost the same - you just have to be aware of that the globals you are sharing are the declared ones of the instance that are loaded (not the ones stored in the script files on disk)."


Regards,

____heb____________________
Harald E Brandt     http://bragit.com

_______________________________________________
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>)



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.