I’ve recently added use framework "Cocoa" to be able to customize the included AppleScript progress window (disable the Stop button and hide the window while the script is still running) to some already existing scripts of mine.
I noticed a few new issues where some things started not working which used to work fine. This lead me to these two posts:
Both of these posts have good information about this issue, and both are fixable by using tell current application, but I’m curious if there are anymore know Scripting Additions commands (or any other AppleScript stuff) that have issues when using Cocoa.
I figured if anyone knows the rhyme or reason or has a list of known conflicts, it’d be the folks on here.
I’m plan on doing a full audit on the scripts where I recently added Cocoa, but I figure it’d be a lot simpler to just have a list of known issues like these to look out for when using Cocoa in AppleScript.
When framework “Cocoa”'s used, set volume works with the now-deprecated small integer direct paramer (0 - 7), but doesn’t understand the more modern labelled parameters.
@ShaneStanley, so does that mean that the AppleScript compiler looks for terms starting at the top of the list?
IOW, does that mean that by putting use scripting additions at the top that your script will use those terms before it tries to use terms from the lower “use” statement?
@NigelGarvey Sorry I wasn’t clear about the open for access issue. It is actually about the file specifier. Also, good to know that the old style set volume (0-7) works as an option as well!
I also found that tell application "Finder" to make new folder at (POSIX file "/Some/Existing/Path") with properties {name:"Testing"} fails when Cocoa is used. But seems to work with the as «class furl» fix, such as tell application "Finder" to make new folder at ((POSIX file "/Some/Existing/Path") as «class furl») with properties {name:"Testing"}
With this new info, the better fix for my Finder code issue is tell application "Finder" to make new folder at ("/Some/Existing/Path" as POSIX file) with properties {name:"Testing"}
Turns out my open for access issue actually had to do with using POSIX file as well, which can be fixed more cleanly with coercion instead of using «class furl» or tell current application as described in the previously linked Gotchas pdf. Such as: open for access ("/Some/Existing/Path/Testing.txt" as POSIX file) with write permission
Thanks so much! It’s great to have peace of mind that there are no other sneaky issues when using Cocoa.
I’m curious, is there any downside to always coercing path strings with as POSIX file? Because of consistency, I’d rather always write ("/Some/Path" as POSIX file) instead of only doing that when using Cocoa and writing (POSIX file "/Some/Path") when not using Cocoa.