Re: Compact Handlers Togo!
Re: Compact Handlers Togo!
- Subject: Re: Compact Handlers Togo!
- From: Paul Skinner <email@hidden>
- Date: Thu, 16 Aug 2001 13:14:53 -0400
on 8/16/01 11:45 AM, Bourque, Jason wrote:
>
> Personally, I like putting my handlers into a script server.
>
> A script server, for those who are wondering, is a script saved as a
>
> stay open application. If there is an asciiSort() handler in the script
>
> server then another script can use that handler by telling the script
>
> server to asciiSort() just as you would tell any application to do
>
> something.
>
>
>
Do you have every handler in a library?
Yes, and No. If I put the text of every handler into a single script it
wouldn't open in Script Editor or Scripter (my preferred editor. ).
What I do instead is declare properties in the script server that hold
the handlers. The handlers themselves can be saved as individual scripts or
lumped together into libraries. I don't like the library way because it
requires using a possessive call to get to the buried handler.
Compare the scripts below with what I posted yesterday. The only
difference is that you don't have the text of the handler in this script
server, just it's 'value'.
Begin example scripts.
--Handler script. Saved as a script. Anywhere you want to put it.
on beeper()
beep 3
end beeper
--scriptserver application. Saved as stay open.
property beeper : load script alias "dark star:Desktop Folder:beeper"
--Handlerless script.
tell application "scriptserver"
beeper()
-->beep,beep,beep
end tell
End example scripts.
>
Is there a problem with file size,
>
memory allocation for the stay open app?
No, I just have to assign it enough memory to hold the contents of all
of it's handler properties and value properties.
Currently my script server is 444k. Remember that the file size (444k)
is reflecting the internally stored handler's data as well as the text of
the application. If I comment out the entire text of the script server and
save it as an application it's only 20k.
I allocate it 6MB of memory. This is because I store large values in
some of the value properties from time to time.
>
>
> Remember that putting globals into your handlers lets the data inside
>
> leak into your script body. Good and Bad. When you have 100 handlers, will
>
> you remember the variable names in the first? Forget them at your own
>
> peril.
>
> Alter them in another handler or in the body and your first handler may
>
> misbehave.
>
>
>
Good point, I will keep that in mind.
>
>
Thanks,
>
>
Jason Bourque
--
"AppleScript is digital duct tape."
Paul Skinner