Re: ARGH - creating a property script
Re: ARGH - creating a property script
- Subject: Re: ARGH - creating a property script
- From: Brennan <email@hidden>
- Date: Wed, 19 Sep 2001 01:37:55 +0200
On 18/9/01 at 3:13 pm, Zavatone, Alex" <email@hidden> wrote:
>
Hopefully, someone with experience creating property scripts could help
>
here.
Do you mean scripts with properties, or something else? You don't mention properties anywhere else in your message.
>
I've taken 5 scripts that work on their own and tried to put them in one
>
script in named routines that can be called from another application.
>
>
This has been saved as a compiled classic app and I try to call the names of
>
the routines from another applescript with
>
>
tell application "uber dialer script" to makeCDSysTCPIPConfig()
>
>
or
>
>
tell application "uber dialer script" to doquit()
>
>
In doQuit, I simply have "quit" sans quotes at this point.
>
>
Questions: When I define the script, does the word script need quotes
>
around it?
No. Maybe you could post some snippets, or use this template;
on run
my abc's doThat()
end
script abc
property rememberThis:"Your wedding night"
on doThis()
-- whatever
end doThis
on doThat()
-- whatever
end doThat
end script
Note: You only need to explicitly declare the script if you have more than one script in the document. If you do, then you'll also need to target the script by name.
>
Any idea what I am doing wrong?
Well, unless you have some reason for "uber dialer script" to remain open, there's no need to save it as an application. A compiled script will do the job just fine with 'load script' from Standard Additions;
set helper to (load script alias "Macintosh HD:wherever:uber dialer script")
Then there's a choice of syntax to call handlers in the loaded script;
tell helper to makeCDSysTCPIPConfig()
helper's makeCDSysTCPIPConfig()
makeCDSysTCPIPConfig() of helper
If 'helper' contains script objects inside itself, let's say it has one called shoeShineBoy, then the syntax for calling one of *its* handlers would be something like this:
tell helper
tell its shoeShineBoy to buffMyBrogues()
end tell
Note that script objects can load external script objects recursively if necessary, or have them embedded inside. You need to use 'its' so that the namespace evaluates properly.
With this approach, there's no need to quit because there's no applet anyway. Just set the helper variable to zero or something when you're done. If you use 'store script' as well, any properties modified in the helper script will persist until you open it and recompile it.
Applets run a little heavy, so try to use as few as possible. If you have the luxury of an attachable app, you don't necessarily need an applet at all.
Often, you can get away with having just one 'applet' which can load ordinary compiled script files on the fly. The advantage of this approach is that you can update the external scripts without having to quit and restart the applet. This is especially handy in CGI work.
If you absolutely must have the helper script running as an application, like maybe it needs to do something on idle, and you just want to tell it to quit, then just
tell application "uber dialer script" to quit
or
tell application "uber dialer script"
someCustomHandler() -- don't forget the parentheses
quit
end tell
HTH
Brennan