suspend applescript execution while application..

Hi folks,
Here is my problem: I launch the application Lotus Notes on a configuration file (Config.nsf for exemple) by applescript:


Tell application "lotus notes" open file "HD:...:Config.nsf"

Well it’s working fine. But now I have to make few opérations in this file, and quit Lotus Notes. After the lotus notes close down, I want to delete the file Config.nsf:

Tell application "lotus notes" open file "HD:...:Config.nsf" (...) Select file "HD:...:Config.nsf" delet selection empty trash

I just need to know how to suspend the script execution to delete the file config.nsf after I quit Lotus Notes.
Somebody can help me? Is this possible? I’m just a beginner in Applescript.
Thanks a milion for an answer.

I think you want a script that launches Lotus Notes with the given file, then waits until Lotus Notes isn’t running, then deletes the file.
Probably the best thing to do is to save it as stay-open application and include an idle handler that checks every minute (or so) to see if Lotus Notes is running. If not, then it deletes the file. This means that you may have a short period of time where the file still exists after you quit Lotus Notes. Would that work? If so, here’s a quick outline:

 on run
Tell application "lotus notes" open file "HD:...:Config.nsf" end
on idle
-- ADD Code here to check if Lotus Notes is running - a sample is probably in archives here if isRunning then
return 60 -- wait 60 more seconds before checking else
tell application "Finder"
delete file "HD:...:Config.nsf"
empty trash
end tell end if end idle

That’s pretty much what you’d want. If you need something that happens immediately, you could shorten the idle return period, but that may start to have a noticeable effect on performance.
There may also be some software that monitors what apps are running and automatically calls a script when you quit Lotus Notes…

Another approach would be to use the free scripting addition “Sleep Commands”, written by E. A. Grant. It provides a command that suspends script execution until a specified application is no longer running.

How about using 2 scripts: 1 that launches Lotus Notes; and a 2nd that runs when Lotus Notes quits or the file is closed.

I do not have Lotus Notes so I don’t know if this is a good approach or not. Just another way of looking at it.

Brad Bumgarner