Re: Script Objects
Re: Script Objects
- Subject: Re: Script Objects
- From: JJ <email@hidden>
- Date: Thu, 17 Oct 2002 09:15:57 +0200
>
Hi
Hi!
>
I'm trying to run this script:
>
>
script checkServerStatus
>
>
property serverName : ""
>
>
to checkThisServer to thisServer
>
>
set serverName to thisServer
>
>
if not (disk thisServer exists) then
>
>
beep
>
display dialog "The " & thisServer & "needs to be mounted in order for this
>
script to function."
>
>
end if
>
>
end checkThisServer
>
>
end script
>
>
tell checkServerStatus
>
set thisServer to "StorageServer"
>
tell checkServerStatus to checkThisServer to thisServer
>
end tell
>
>
but I keep getting the following error message:
>
>
<<checkServerStatus>> doesn't understand the disk message
I can't _compile_ this script. I think "disk" is a Finder-only class and you
need it in a "tell" (finder) block.
/ - / - / - / - / - / - / - / - / - / - / - / - / - / - /
tell application "Finder"
disk x
end tell
/ - / - / - / - / - / - / - / - / - / - / - / - / - / - /
>
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? Is there another way to do this? Also, how would I call
>
the script object from another script - do you use the path to the script
>
something like this:
You can use a script object, but you don't need it. The handler is good
enough:
/ - / - / - / - / - / - / - / - / - / - / - / - / - / - /
to checkThisServer to thisServer
tell application "Finder" to set y to (exists disk thisServer)
if not (result) then
beep
display dialog "The " & thisServer & " needs to be mounted in order
for this script to function."
end if
end checkThisServer
set thisServer to "StorageServer"
checkThisServer to thisServer
/ - / - / - / - / - / - / - / - / - / - / - / - / - / - /
But perhaps your check function will be quickest if you don't "need" the
Finder in your business:
/ - / - / - / - / - / - / - / - / - / - / - / - / - / - /
to checkThisServer to thisServer
try
thisServer & ":" as alias
on error
beep
display dialog "The " & thisServer & " needs to be mounted in order
for this script to function."
end try
end checkThisServer
set thisServer to "StorageServer"
checkThisServer to thisServer
/ - / - / - / - / - / - / - / - / - / - / - / - / - / - /
>
tell desktop folder:AppleScripts:scriptObjects:checkServerStatus
>
set thisServer to "StorageServer"
>
tell checkServerStatus to checkThisServer to thisServer
>
end tell
To call a handler on a "remote" script, you must "load" the script:
/ - / - / - / - / - / - / - / - / - / - / - / - / - / - /
set script_location to (choose file) -- a simple alias to the script
set server_checker to (load script script_location)
/ - / - / - / - / - / - / - / - / - / - / - / - / - / - /
Then, work with it as if it was an application, and its handlers its
commands:
/ - / - / - / - / - / - / - / - / - / - / - / - / - / - /
tell server_checker
checkThisServer to "StorageServer"
end tell
/ - / - / - / - / - / - / - / - / - / - / - / - / - / - /
JJ
Faith Hill - Exclusive Performances, Videos & More
http://faith.yahoo.com
_______________________________________________
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.