Mount volume and error code testing


In pseudo code I need to do this with AppleScript

Try to mount volume zzz
If error code = volume already mounted
Do nothing
Display error message
end if

As I am an absolurte beginner with AppleScript under OS X, can someone help me?


Something like this:

repeat with k from 1 to 2
	set myDiskName to item k of {"XYZ", "Network"}
	tell application "Finder" to if name of every disk does not contain myDiskName then
		display dialog myDiskName & " is not available"
		beep 3
	end if
end repeat


It’s exactly what I need, but I need some more details…

In your example how can I use the myDiskName variable to complete a line like this:

mount volume “afp://” as user name “BEKTASHI Elif” with password “linda”

How do you combine static text with variable content in AppleScript?

Thanks for your help.

Also is there a structure like this in AppleScript:

Case of
do this
do this
do this
En case

AppleScript uses nested ifs to do ‘case of’:

set L to {1, 2, 3, 9}
repeat with N in L
	set T to contents of N -- N is a reference to the item in the list
	if T is 1 then
		display dialog "1"
	else if T is 2 then
		display dialog "2"
	else if T is 3 then
		display dialog "3"
		display dialog "Its big"
	end if
end repeat

AppleScript uses ‘&’ to concatinate text and lists, so:

mount volume ("afp://" & myDiskName) as user name "UName" with password "myPW"