try
tell application "Finder" to alias disk username
-- if it makes it this far, a disk named username was detected.
on error
-- a disk named username wasn't found so let's try to mount the iDisk.
try
mount volume "http://idisk.mac.com/username/" as user name "username" with password "password"
on error mountError
display dialog mountError
return -- terminate execution of the rest of the script
end try
end try
Run it again and I get “File some object busy”.
The error is remove by removing these lines
on error mountError
display dialog mountError
return – terminate execution of the rest of the script
But the script shouldnt get this far anyway because the idisk “username” is already on the desktop.
What’s abetter way to test to see if a disk is present rather than
tell application “Finder” to alias disk username
This is not the official explanation and corrections are likely to follow.
You can save a script as:
Text: Not compiled, can be viewed in a text editor. When you reopen it in a script editor, it won’t ask/look for applications/scripting additions that are called in the script. This is a nice way to save copies for backups or for other scripters who might want to look at the code even if they don’t have all of the required applications/scripting additions.
Application (aka applet): This allows the script to be executed by double clicking the icon, just like any other application.
Compiled: The script has been compiled (really?!) and, in a nutshell, it has verified that all called applications/scripting additions are present. It also resolves alias references. This is a good way to save scripts when an application isn’t required and when the script will be run from script menus and other utilities that can run scripts.
Run only: Keeps others from viewing your complete source code and results in smaller files. This should not be considered safe/secure for protecting passwords or other sensitive data since plain text in run only scripts can still be discovered with relative ease.
Just to add to Rob’s statement about saved as a text file…
It’s also handy for saving a script that you’ve been working on that will not complie, but you would like to keep what you have so that you can get back to it at a later time.