more newbie help plz - this should be simple

Thanks to everyone who has helped me this far… :slight_smile:

I’m writing a script that’s run automatically from within filemaker when the database is opened. Since the script is being run from within the filemaker app itself, it keep filemaker busy until the script is completed. What I"m trying to do is to mount a remote volume that the database needs to access. Part of the debugging process is dealing with the contingency of if the volume is not available or takes too long to mount.

Craig Williams helped me solve the problem of Finder being kept occupied while the volume is being mounted - THANK YOU!
http://bbs.macscripter.net/viewtopic.php?id=27836

The second part of the equation is that because the script is being run from within Filemaker, filemaker is unaccessible until the script completes - which is a two minute time out if the volume is not available. It seems like an eternity to wait, especially is I know the volume is not available but want to get into the database anyway. Ideally, I would like to set the script in motion to mount the volume and then continue on to filemaker and allow the script to finish in the background, but filemaker is kept busy for as long as the script is running, even if I ‘tell application “FileMaker Pro” to activate’.

I wish I could separate the script from filemaker and run it independently, but that’s not possible as this has to be an all inclusive solution, and it seems that I cannot call an external applescript from within filemaker.

Since I can’t run the script in the background or independently of filemaker, the best thing I can think of is to allow the user to cancel the script if it’s taking too long. Here’s what I have in mind, but I have no idea how to go about it:

Display a dialog - “trying to mount the volume” with a cancel button
script continues to the next step, trying to mount the volume, while dialog is still displayed
if the user clicks “cancel” in the dialog at any point during the mount process, the script exits.

What I can’t figure out is how to 1) make the script display the dialog and then continue to the next step (it seems to have to wait for an answer before it continues)
and 2), make the script “watch” for the cancel input from the user and exit when the button returns “cancel”.
It makes sense to have the script loop or repeat until button returned is “cancel”, but I can’t figure out how to do this while also performing the ‘mount volume’ step.

I’ve played with looping, ignoring, repeat, and several variations, but I’m a little lost.

Any help?
Thanks in advance!

I believe you want something like this:


set n to 30
set x to button returned of display dialog "Trying to mount the volume..." giving up after n

where n is in seconds.

It won’t compile :frowning: I don’t think that’s what I need though - unless I’m reading it wrong, this appears to time out the script after 30 seconds.

What I’m trying to do is mount a volume, but allow the user to cancel the script with a dialog containing a cancel button in the case that the volume may not be available (so they don’t have to wait the entire two minutes for it to timeout). Here’s what I’ve got so far - or more accurately, what I’m trying to do:

try
	tell application "Finder" to disk "Video"
on error
	
	display dialog "Trying to mount the Video folder" buttons {"Stop"}
	mount volume "afp://macserver:video@192.168.254.20/Video"
end try

I whipped the dialog part in there to try and demonstrate what I have in mind. Of course, it doesn’t currently work as desired, because there’s aot of it missing - like what to do with the button result etc etc, but I’m not sure how to even get past this step: The script pauses to wait for me to click the button in the dialog before continuing on to the mout volume step, and what I want it to do is continue to try and mount the volume without the dialog being answered, while the dialog is displayed the whole time until the volume is mounted or times out. If, at some point, the user gets tired of waiting, they can click “stop” (it could be cancel, as well, since that cancels the script) and the script will exit. But how do I make the script ‘monitor’ for the button press while continuing to do the ‘mount volume’ step?

aargh! a little lost here - I just don’t know the syntax to get this done.

You might try:

ignoring application responses
Tell application "Finder"
-- mount command...
end tell
end ignoring