Handler confusion

Hi all,

I’m expanding my vocabulary on Applescript and have recently started using handlers. I have one that works when run by itself, but when I put it in the main script, I get the following message:

Can’t make <> into type string.

and I’m trying to insert this directly after an if statement


global net_macinfo
set net_macinfo to MountBackupServer
MountBackupServer()
display dialog net_macinfo

on MountBackupServer()
	set user_name to do shell script ("whoami")
	set first_letter to do shell script ("whoami | cut -c1-1")
	set backserver to do shell script ("mount | grep 'back-data' | cut -f5 -d/ | cut -f1 -d-")
	if backserver is equal to "back" then
		set dfsmount to do shell script ("mount | grep 'back-data' | cut -f1 -d\\( | cut -f8 -d/")
		
		set net_primary to do shell script ("cat /Volumes/" & dfsmount & "/.macinfo | grep PRIMARY= | cut -f2 -d=")
		set documents_exist to do shell script "ls /Volumes/" & dfsmount
		
		
	end if
	if backserver is not equal to "back" then
		mount volume "cifs://office.ads.gvsu.edu/dfs/back-data-" & first_letter & "/" & user_name
		set dfsmount to do shell script ("mount | grep 'back-data' | cut -f1 -d\\( | cut -f8 -d/")
	end if
	set net_macinfo to do shell script ("ls  -al  /Volumes/" & dfsmount & " | grep .macinfo| cut -f2 -d.")
	set net_primary to do shell script ("cat /Volumes/" & dfsmount & "/.macinfo | grep PRIMARY= | cut -f2 -d=")
	set documents_exist to do shell script "ls /Volumes/" & dfsmount
	return net_macinfo
end MountBackupServer


Thank you for any help on this!

mountBackupServer variable is an handler. You can’t have an variable with the same name as an handler. So I’m guessing that line 2 should be:

set net_macinfo to "MountBackupServer"

or if you want the results of the handler in the net_macinfo variable you forgot the parenthesis but then line 3 doesn’t make any sense to me.

set net_macinfo to MountBackupServer()

I got it figured out! I was putting my global sets in the wrong place. I think. Regardless, it works and I’m happy!!!