Is there a better way to do this?
When I am debugging a script using Myriad Tables I used to manually set a debugging variable to true, and then MT is run in a separate app. When I turn off debugging it runs MT from within the script, which it also does when run live as an applet or from a scripts menu.
Now, I’m using the handler below to set that variable, but it seems rather clunky and I’m not sure how reliable it will be.
Is there a better way to tell if the current script that is executing is in Script Debugger with Debugger enabled? (That is the only context where I would use the separate app).
set debugging to IsThisScriptRunningWithDebuggingEnabled()
on IsThisScriptRunningWithDebuggingEnabled()
tell application "System Events"
try
set sdRunning to exists (application process 1 whose name is "Script Debugger")
on error
set sdRunning to false
end try
if not sdRunning then
set debugging to false
return debugging
end if
--application process "Script Debugger"
end tell
tell application "Script Debugger"
set myPath to (path to me as text)
set myFileSpec to (get file spec of front document)
--» If THIS script document is FRONTMOST check if debugging is enabled
if myFileSpec is missing value then -- new, unsaved script is running in SD
set runningScript to a reference to document 1
else if myPath = (myFileSpec as text) then
set runningScript to a reference to document 1
else
set debugging to false
end if
tell runningScript
set debugging to debugger enabled
end tell
end tell
return debugging
end IsThisScriptRunningWithDebuggingEnabled
→ Mac OS: 14.6.1 (23G93)
→ Script Debugger 8.0.10 (8A88)
→ SD Notary 2 2.0 (102)
→ FastScripts 3.3.4 (1910)