I’m having a new issue that seems to have crept up in 7A41. (I’ll upgrade to 45 soon, but it doesn’t seem this has been addressed).
I’ve been running the script below for months. Today when I tried to copy all text in a script in the only script window open (using Select All), I got an error message that SD couldn’t get the selected text of the script.
The script worked on other script windows (including its own) but would not work on this other window with all the text selected. It did work if I had a single line selected, but not if I had a chunk of text selected.
The script window had not been saved so I saved it and it still didn’t work. Same error each time.
set whichWindow to 1
tell application "Script Debugger"
   properties of window whichWindow
   set selectedText to the selection of window whichWindow
   set entireScript to source text of current document of window whichWindow
end tell
set AppleScript's text item delimiters to {return}
set entireScript to {"```AppleScript", entireScript, "```", ""} as text
if selectedText is not "" then
   set selectedText to {"```AppleScript", selectedText, "```", ""} as text
   
   set dialogText to selectedText
   set userPrompt to {"Displaying Selection from Current Script", "", ¬
      "Edit as needed to post on Script Debugger Forum,", "", "Or Copy Entire Script", "", "Click \"Cancel\" to exit without changing the Clipboard"} as text
   set currentDefault to "Copy Selection"
   set displayMode to "Selection"
else
   set displayMode to "Entire Script"
end if
try
   tell application "Script Debugger"
      repeat
         if displayMode is "Selection" then
            set dialogText to selectedText
            set userPrompt to {"Displaying Selection from Current Script", "", ¬
               "Edit as needed to post on Script Debugger Forum,", "", ¬
               "Or Copy Entire Script", "", ¬
               "Click \"Cancel\" to exit without changing the Clipboard"} as text
            set currentDefault to "Use Selection"
            set dialogButtons to {"Cancel", "Use Selection", "Copy Entire Script"}
         else
            set dialogText to entireScript
            set userPrompt to {"Displaying entire current script", "", ¬
               "Edit as needed to post on Script Debugger Forum", "", ¬
               "Click \"Cancel\" to exit without changing the Clipboard"} as text
            set currentDefault to "Entire Script"
            set dialogButtons to {"Cancel", "Entire Script"}
            
         end if
         --DisplayDialog Full
         set userInput to display dialog userPrompt ¬
            default answer dialogText ¬
            buttons dialogButtons ¬
            default button currentDefault ¬
            with title ¬
            "Quote " & currentDefault
         set {userText, userButton} to {text returned of userInput, button returned of userInput}
         if the userButton is "Use Selection" then
            if displayMode is "Selection" then
               set the fourmText to userText
               exit repeat
            end if
         else if displayMode is "Entire Script" then
            
            set the fourmText to userText
            exit repeat
         else
            set dialogText to entireScript
            set displayMode to "Entire Script"
            
         end if
      end repeat
      set fourmText to my ReplaceText(tab, "   ", fourmText)
      set the clipboard to fourmText
   end tell
   return the clipboard
on error errMsg number errNum
   -- your error handler code goes here
end try
on ReplaceText(findString, replaceString, textToFix)
   set saveTID to AppleScript's text item delimiters
   set AppleScript's text item delimiters to {findString}
   set textToFix to every text item of textToFix
   set AppleScript's text item delimiters to {replaceString}
   set textToFix to textToFix as text
   set AppleScript's text item delimiters to saveTID
   return textToFix
end ReplaceText
–>  Script Debugger 7.0.1 (7A41)
–>  Script Debugger 6.0.8 (6A225)
–>  Mac OS 10.11.6 (15G1611)
 
           
          