Is there a way to check if debugging-mode is enabled at runtime?

Is there a way to check if debugging-mode is enabled at runtime?

In debug-mode, I use the line property XX: document "YYY", but otherwise I use this line: use XX : script "YYY".

Is there some way (like #ifdef DEBUG in C) to switch between those lines?

I was just wondering about it; it’s not a clear cut, because I also the second form (use) in debug-mode… It’s nothing too important.

You could using something like this:

on isDebuggingEnabled()
	if id of current application begins with "com.latenightsw.ScriptDebugger" then
		tell current application
			tell (first document whose (name is (my name) or name begins with ((my name) & ".")))
				return its debugger enabled
			end tell
		end tell
	end if
	return false
end isDebuggingEnabled

isDebuggingEnabled()
1 Like