Passing information from script to app

I have an AS Studio app that I’m building that is meant to mount SMB shares. It collects the username as a variable to map the correct share, and I’d like to pass the username on to the SMB/CIFS login dialogue, but how to do that just isn’t clicking or I’m not finding the correct information.

help?

How are you mounting the remote volumes?

If using the built-in ‘mount volume’ command, it accepts additional parameters ‘as username ’ and ‘with password ’

IIRC, providing either of these values populates the authentication dialog.

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 "usetype" of window "main"
		set mountMe to theServerToMount & "/" & theSharename & "$" as string
		tell application "Finder"
			try
				mount volume "smb://" & mountMe as user name theSharename
			end try
		end tell
	else if title of theObject is "Cancel" then
		quit
	end if
end clicked

this doesn’t seem to be working. When I compiled and ran it, the username was still populated with my local username, not the one that I input.