Mount volume and error code testing

Hello,

In pseudo code I need to do this with AppleScript

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

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

Thanks

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"
	else
		beep 3
	end if
	
end repeat

Thanks,

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://10.192.120.117/myDiskName” 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
k=1
do this
k=2
do this
k=3
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"
	else
		display dialog "Its big"
	end if
end repeat

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


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