###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)
--- CHOOSE, & RE-RUN SCRIPT ---
-- 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
else
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.