On 10/31/04 6:33 AM, "T&B" <email@hidden> wrote:
> 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.
Take it further. Use the "Model-View-Controller" system. Have only one
Controller script, which has all the event handlers as entered from IB.,
which respond to user events in the app. Use as many Model scripts, where
you do all the "action" scripting, auxiliary application scripting, etc. as
you need or want for modularization purposes. Instead of using 'global',
make it a script property in the main script. (Since properties are not
retained between quits, it amounts to the same thing, but it easier to
handle.) Like this:
property otherScriptLib : missing value
on loadScriptLib()
if class of otherScriptLib is not script then
set otherScriptLib to load script POSIX file (path for script
"OtherScript" extension "scpt"
end if
end loadScriptLib
Then, every time you refer to otherScriptLib anywhere, precede it by
loadScriptLib()
That ensures that the first time it will load it and the other times it does
nothing. (You can never be sure in an ASS script which call will come
first.) You can even make separate script objects in other script files and
set properties to each script object in the main script.
> 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.
I wouldn't worry about it. "OtherScript" is being run only from the main
controller script which loads it. Any memory involved in simply having the
compiled script hanging about at launch time must be quite negligible.
--
Paul Berkowitz
_______________________________________________
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