Format and flow

I dislike asking such a newbie question like this, but I’m running out of time and I have to get my project done.

The script is supposed to mount a share. The server name is variable and so is the share name.

Server is to be selected via a popup menu. There’s only Choice1 and Choice2
Sharename is dependant upon what’s entered into a text field.

how should this look? I’m just not sure what goes where in what order.

This assumes you have a text field named “shareName” and a popup button “popupMenu” in a window named “main”

then you get the contents of the text field and the selected popup menu item. Place them into a string and then mount the server.

Add error handling in case a user didnt put in a share name.


on clicked theObject
set theSharename to the contents of text field "shareName" of window "main"
set theServerToMount to the title of popup button "popupMenu" of window "main"
set mountMe to theServerToMount & "/" & theSharename as string
mount volume "afp://" & mountMe

end clicked

This was a great help! Thanks! :smiley: things are starting to click in my head (I ditched this for a while and am now coming back to it)

so far this is what it looks like:

on clicked theObject
	if title of theObject is "Connect" then
		set theSharename to the contents of text field "username" of window "main"
		set theServerToMount to the title of popup button "usertype" of window "main"
		set mountMe to theServerToMount & "/" & theSharename & "$" as string
		tell application "Finder"
			try
				mount volume "smb://" & mountMe
			end try
		end tell
	else if title of theObject is "Cancel" then
		quit
	end if
end clicked

I’m letting the OS handle the authentication, instead of sending the “username:password@server/share” method, in the hopes of having a tad bit more security.

Now I’m trying to figure out how to autofill the Username and to have the script to close upon succesful mounting of the share