How Do I Handle Multiple Versions of SD?

I have a script to open some text in a Script Debugger document, but I don’t know how to allow for different versions of SD.

The user might have just one version of SD, or 3 versions.
I want to use the latest version the user has installed.
How would I do that?

Here’s my current script:

on openScriptInSD(pScriptStr)
  tell application "Script Debugger 7"
    set oDoc to make new document with properties {source text:pScriptStr, debugger enabled:true}
    tell oDoc to compile
  end tell
end openScriptInSD

If I use tell application "Script Debugger", then it opens SD6.

You can address specific versions by bundle ID:

tell application id "com.latenightsw.ScriptDebugger7"
	id --> "com.latenightsw.ScriptDebugger7"
end tell

com.latenightsw.ScriptDebugger7 : Script Debugger 7
com.latenightsw.ScriptDebugger6 : Script Debugger 6
com.latenightsw.ScriptDebugger5 : Script Debugger 5

1 Like

Using what @alldritt has posted, you could do something like this:

repeat with i from 8 to 5 by -1
		set theApp to application id ("com.latenightsw.ScriptDebugger" & i)
		exit repeat
	end try
end repeat
using terms from application "Script Debugger"
	tell theApp
		-- do your thing
	end tell
end using terms from
1 Like

Very cool, Shane! :+1:

This is perfect for what I need.

Well, darn. As soon as I compiled your script using SD7, it changed that statement to:
using terms from application "Script Debugger 7"

It added the “7”.

Same result using Script Editor.

Any ideas?

That doesn’t matter. That statement is just specifying the application to be used at compile time — it’s ignored at run time. You just need to make sure you don’t use any 7-only code.

1 Like