script behaves differently after running once

Running this script once is ok, my iDisk mounts

	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. 
		mount volume "" 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


The error also goes away if I change

tell application “Finder” to alias disk username


tell application “Finder” to disk username

Is this a better way to check and see if a disk is there?

It’s one way, but why not use the ‘exists’ command and avoid the need for the error handler:

tell application "Finder"
   if not (exists (disk "diskname")) then
      mount volume "blah blah blah..."
   end if
end tell

You can save an applet as
compiled script

You can also save as ‘run only’ to applicatio and compiled script.

Can someone point me to a clear description of the differences. Tnx.

This is not the official explanation and corrections are likely to follow. :wink:

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.

There’s a bit of related info at:

– Rob


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.