Re: Script Objects
Re: Script Objects
- Subject: Re: Script Objects
- From: has <email@hidden>
- Date: Wed, 16 Oct 2002 21:13:20 +0100
Steve Suranie wrote:
>
I'm trying to run this script:
[...]
>
but I keep getting the following error message:
>
>
<<checkServerStatus>> doesn't understand the disk message
You forgot to wrap a 'tell application "Finder"' block around 'disk
thisServer exists'.
>
Any help would be appreciated. I'm trying to check if certain servers are
>
mounted before I continue with a script. Since on most of the scripts I
>
write I have to check servers I thought I would just write a script object
>
and pass along to it which server(s) I am checking. Am I not understanding
>
the concept of the script object?
Probably not. But I wouldn't sweat it much if I were you...
Assuming you want to create a reusable library/module that'll allow you to
share the same piece of code amongst multiple scripts without lots of
copy&paste [ugh], that's pretty easy:
Library script:
-------
to checkThisServer(thisServer)
...
end checkThisServer
-------
Save this to disk somewhere convenient. I tend to use the Scripts folder on
OS9; it seems as good as any place for storing general-purpose libraries.
[Unfortunately, there isn't an official "AS Libraries" folder in AS as
there is for Scripting Additions... just one more _basic_ feature that
every language _except_ AS seems to have...<sigh>]
Client script:
-------
property serverLib : load script (alias "path to your library script here")
...
tell serverLib to checkThisServer("StorageServer")
-------
That loads a fresh instance of your library script into the serverLib
property at compile-time (simplest); you can then call its handlers from
anywhere in your client script.
Very straightforward: the sort of by-rote solution you can do blindfolded
(i.e. you don't need to be a script object expert in order to use it). HTH
has
--
http://www.barple.pwp.blueyonder.co.uk -- The Little Page of AppleScripts
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.