Ok, so I wrote a droplet to move items to a given folder on the fileserver. First, however, the user must present a password to ensure that the user is, in fact, the person for whom this script was written. I want the entire script to halt if the user fails
if text returned of the result is "the_password" then
Right now, it won’t mount the volume in the following line if the user fails the password, but it will display the dialog that begins "All done. Your stuff. . . " How do I get the whole think to halt if the user fails the first “IF THEN?” Here is the script:
on open
tell application "Finder"
activate
set theItem to selection
display dialog "Not so fast, buckaroo. I gotta know Mia's File_Server password first. Please enter it below" with icon stop default answer ""
if text returned of the result is "the_password" then
mount volume "afp://username:password@IP_Address/Disk_Name"
else
display dialog "Sorry, Charlie" buttons {"Drat"} default button "Drat"
end if
try
move theItem to folder "Mcaolo" of folder "Target_Folder" of disk "File_Server"
end try
display dialog "All done. Your stuff is now in the Mcaolo folder. Would you like me to open it for you?" buttons {"Sure", "No, not really"} default button "Sure"
set button_name to button returned of the result
if button_name is "Sure" then
open folder "Mcaolo" of folder "Target_Folder" of disk "File_Server"
else
put away disk "File_Server"
end if
end tell
end open
I tried to but an “end tell” and a new “tell” between the lines “end try” and “display dialog” to no avail. Help? Thanks folks.
The answer to your question is to insert “return”. That takes the script back to where it came from before entering the ‘on open’ handler - in this case to the top level, where there is nothing else for the script to do and so it quits. I have taken the liberty of altering another couple of details.
on open (theFiles)
tell application "Finder"
activate
-- set theItem to selection
display dialog "Not so fast, etc" with icon stop default answer ""
if text returned of the result is "the_password" then
mount volume "afp://username:password@IP_Address/Disk_Name"
else
display dialog "Sorry, Charlie" buttons {"Drat"} default button "Drat"
return
end if
try
move theFiles to folder "Mcaolo" of folder "Target_Folder" of disk "File_Server"
on error
-- routine for dealing with an error
end try
Andreas
PS Looking at what I just posted I see that ‘activate’ is superfluous. To be using the thing as a droplet you have to be working with icons in the Finder.
Andreas
: The answer to your question is to insert “return”. That
: takes the script back to where it came from before entering
: the ‘on open’ handler - in this case to the top level, where
: there is nothing else for the script to do and so it quits. I
: have taken the liberty of altering another couple of
: details. on open ( theFiles )
: tell application “Finder”
: activate
: --set theItem to selection
: display dialog “Not so fast, etc”
: with icon stop default answer
: “”
: if text returned of the result
: is “the_password” then
: mount volume
: “afp://username:password@IP_Address/Disk_Name”
: else
: display dialog “Sorry, Charlie”
: buttons {“Drat”} default button
: “Drat”
: return
: end if
: try
: move theFiles to folder
: “Mcaolo” of folder
: “Target_Folder” of disk
: “File_Server”
: on error
: – routine for dealing with an error
: end try
: – etc Andreas
Hey, thanks a lot. Not too bad, eh?
If it HAD been too bad I wouldn’t have touched it with a bargepole, would I?
And I see a bit of real class creeping in!!
Andreas
I see a bit of real class creeping in !!
As Homer Simpson would say. . . Woohoo!