SD6 Build 6.0.4 Issue -- Finder Looses Selection


(Jim Underwood) #1

###SD6 Build 6.0.4 Issue – Finder Looses Selection
Script Debugger 6.0.4 (6A198) on macOS 10.11.6

This is a very strange, confusing issue. The following script errors when immediately re-run on my Mac #1 in SD6, but runs fine on Mac #1 Script Editor, and on Mac #2 SD6.

The script runs fine the first time, after a folder was selected in the Finder, and then I switch to SD6 and execute the script. But if I immediately re-run the script, it fails. The error says that the Finder does NOT have a selection. What happened to it?

Can anyone reproduce this behavior?
Is there a workaround?

ON Mac #1:  Script Debugger 6.0.4 (6A198) on macOS 10.11.6
  • Brand New iMac 27 Just setup
  • Get error on re-run
ON Mac #2:  Script Debugger 6.0.4 (6A198) on macOS 10.11.6
  • MBP-15R been running for 4 years
  • Re-run works fine

tell application "Finder"
  set itemList to the selection
  set itemNameList to my getItemName(itemList)
  -- FAILS on Mac #1 on Re-run
  -- ERROR:  Finder got an error: List is empty.
  set ansList to choose from list itemNameList
end tell

on getItemName(pFinderItemOrList)
  if (class of pFinderItemOrList is list) then
    set nameList to {}
    repeat with iItem in pFinderItemOrList
      set end of nameList to (name of iItem)
    end repeat
    return nameList
    return name of pFinderItemOrList
  end if
end getItemName

P.S. I know this handler is sub-optimum, but it works. I am planning to revise per other discussion in this forum.

(Mark Alldritt) #2

I ran your code here on my 10.12.4 machine and I get no errors and the Finder’s selection is preserved.

(Ed Stockly) #3

runs fine here
–>Script Debugger 6.0.5 (6A202) on Mac OS 10.10.5 (14F27)

(koenigyvan) #4

Here, running SD 6.0.4 under 10.12.4
at first run, I got the list :slight_smile:
{“Microsoft Excel.sdef”, “Microsoft Word.sdef”, “Attachments from Notes”, “Libraries handlers.rtf”, “laïcité.pdf”, “with quarantine.pages”, “ASObjC handlers.scpt”, “count files in clipboard.scpt”, “CR2017-51.pdf”, “WakeUp Tune.scpt”, “headphones-fire-696x418.jpg”, “waitForWake.scpt”}

At second run I got a list of a single item
{“pour Late Night web page.rtf”}

If i change the selection then reselect the original set I get the entire list.

You recognize the format of the list as it’s given in Apple’s Editor because I tested in it also and got exactly what I got in SD.
There is clearly a problem but it seems that it’s an Apple one.

PS I assumes that Ed uses a beta version because here SD claims that 6.0.4 is the current version.