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"
activate
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.
Using what @alldritt has posted, you could do something like this:
repeat with i from 8 to 5 by -1
try
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
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.