While I’m working on a script (or reading this forum), I save all kinds of script fragments in a special folder that has now grown too large. To sort through that, I’m writing a script to present each of the files by name in a dialog that lets me leave it, move it to permanent storage, or open it in the Script Editor to see what it is (my file names are sometimes obtuse). If the choice is to leave it, another dialog lets me select “Keep Here” or “Move to Trash” with obvious results (a second dialog is necessary because a Panther AS Dialog can’t have 4 choices, i.e. Keep, Move, Open, Trash).
My problem is with the “Open” selection. Telling the Script Editor to open the file is fine, but how do I stop the script so I can look at the file, and then get back to the script? Is my only choice to open the file for access and inhale the text for presentation in a dialog so the script will stop until the dialog is dismissed?
Why not use a list selection if you want 1 prompt?
Truely poetic!!
You could actually open the file, followed by a display dialog “Continue” w/timeout of a max time you estimate you look at a file’s contents. Exit repeat included for testing purposes:
After the dialog display I set the Script Process to the frontmost so when you click OK the next script comes back to the front. This requires saving to application with a name to work. I didn’t include all the choices in the “if” section.
set choicelist to {"Keep", "Move", "Open", "Trash", "Exit"}
set thefolder to (choose folder)
tell application "Finder" to set theFiles to name of (files of thefolder)
repeat with thisfile in theFiles
set ThisScript to (thefolder as string) & (thisfile as string)
set ThePrompt to ("Current Script: " & (thisfile as string))
set MyChoice to choose from list choicelist with prompt ThePrompt
if MyChoice contains "Open" then
tell application "Finder" to open alias ThisScript
with timeout of 300 seconds
tell application "System Events" to display dialog "Continue"
end timeout
--your script name here
tell application "System Events" to set frontmost of process "untitled 5" to true
else
if MyChoice contains "Exit" then exit repeat
--All other choice conditions here
end if
end repeat
Thanks, SC. I love this forum. In the meantime I had worked something out but using a choice from a list as you’ve proposed means that a whole bunch of second dialogs and if tests to find out more about what to do can be scrapped.
I had also worked out that to deal with the file I could use this fragment:
tell application "Script Editor"
open (item j of SFiles)
display dialog "Click " & "\"OK\"" & " or press " & "\"Return\"" & " when finished reading" buttons {"OK"} default button 1
close window 1
end tell
Thanks again. I may actually learn how to do this efficiently someday.
Yes - I’d forgotten about that. I could stuff a few lines into a stay open until clicked FastScripts or Growl notification and pop up a dialog to get out at the same time. (Neither FastScripts nor Growl will return anything from a note)
Afternote: Absolutely has to have a timeout on a dialog because a long script will put the OK button out of sight off the bottom of the screen. Fortunately it is the default so pressing return gets rid of it. I’ll use FastScipts notification instead.