Re: Fast Loading & updating of Handler Libraries
Re: Fast Loading & updating of Handler Libraries
- Subject: Re: Fast Loading & updating of Handler Libraries
- From: "Serge Belleudy-d'Espinose" <email@hidden>
- Date: Tue, 13 Nov 2001 21:07:45 +0100
At 12:52 -0500 13/11/01, Bourque, Jason wrote:
>
Can the library be over 32k? How big is too big?
A library can be way beyond 32k, the limit only apply to editing the library with SE, but anything else than SE will edit ok.
>
What would be a good common place in both OS 9 and X?
There is an ongoing debate about the best location. Some say scriptings additions, some others say scripts. Scripting additions is supposed to be more compatible especially under X; however, if you have too many libraries you want to organize with subfolders, you face a bug under 9 having folders in scripting additions. Scripts folder doesn't have such problem, but I've been told - and not confirmed myself since I'm not running X yet - that there are permission problems under X.
>
How is this location best addressed. "Path to" or ??? ?
Whether it is scripts or scripting additions, there are system constants for both:
path to scripts folder
path to scripting additions folder
Use them, they allow you to be hierarchy independant.
>
Is load script or parent property better for this project?
load script and parent properties serve two different purposes but they can be used in combination.
set xLib to load script <file path>
loads the script file into xLib at run time. It can take up to a few seconds with big libraries on slow systems but it allows for greater flexibility, since the handlers are always up to date.
You can also make the variable a property:
property xLib : load script file <file path>
loads the script file at compile time, so there is absolutely no delay when running the child script, but you end up with handlers that can become obsolete if you change the library in the meantime - then you have to recompile your scripts.
If this drawback is not a problem for you, you can take benefit of the parent thing:
property parent : load script file <file path>
the result of load script is not assigned to a variable anymore, it becomes part of the child script, ie you can call the 'parent' handlers as is:
handler_of_the_parent_script()
There is a totally different way of loading handlers which has been discussed a few days ago. You can have your library be a stay-open app, and tell it to copy its handlers to local variables as you can copy objects between applications.
-- script server script
on _echo()
return "echo"
end _echo
-- child script
set xServer to application <file path>
tell xServer
copy its _echo to _local_echo
end tell
_local_echo()
--> "echo"
I'm not very used to this technique; its advantage is that you can copy handlers one by one, without having to load the entire script at once.
Serge
--
\\//\//\// Serge Belleudy-d'Espinose Institut Jacques Monod
// // //
http://www.ijm.jussieu.fr/ Universite Paris VII - Jussieu
//\//\//\\