While the original script worked much better then running the development script in SD there were still times that “Script Editor” would get hung and I would have to stop and manually force quit “Script Editor”. The new script closes all the windows in SE without trying to save the contents of the windows since the script is stored in SD. Then SE quits and restarts. This make it fast and hassle free.
Basically this recreates the way Xcode works without all the trouble that Xcode causes when using it. Using the script to control SE, the script is running in a separate process, and the process is restarted before each run. I have my F1 fiction key set up to invoke the script and all I have to do is press the F1 key and in about a second the script is running on script editor. Then I make changes in Script Debugger and the press the F1 key again and in a second I can see the script entered in SD running on SE.
If you want to step thought a script in SD you still can. “Foundation” and “Quartz” let you do this a fair amount of time, but AppKit crashes more often then it works with the debugger on. But you can still try it and your script might step though it without crashing. Sometimes it does work.
Here is a link to the original announcement of “better way to develop ASObj-C.”
Depending on how fast your Mac is running the delay in the script below might have to be made larger, or you might be able to make it smaller. The number for the delay command is a real number and therefore times like 1.1 seconds is ok.
Here is the new script:
tell application "Script Debugger"
activate
set SDSourceText to source text of document 1
end tell
tell application "System Events"
if name of processes contains "Script Editor" then -- Check if "Script Editor" is currently running
tell application "Script Editor" to quit saving no
end if
end tell
delay 1
tell application "Script Editor"
launch
activate
set DocumentsOpen to documents
if DocumentsOpen ≠ {} then
repeat with TheDocument in DocumentsOpen
close TheDocument saving no
end repeat
end if
set TheDocument to make new document
set text of TheDocument to SDSourceText
compile TheDocument
execute TheDocument
end tell
Bill Kopp