I would like to understand (don’t need to make it work) what’s going on with this library: testlib.scptd.zip (6.8 KB).
Its content script is very short:
use AppleScript version "2.4"
use framework "Foundation"
use scripting additions
set anURL to current application's class "NSURL"'s fileURLWithPath:"/Applications"
--posix from url anURL
--on posix from url anURL
return anURL's |path|() as text
--end posix from url
My question is: why when the lines that uses the sdf’s command (posix from url) are uncommented the script fails?
It’s a limitation of AppleScript: the direct parameter of a command can’t be a Cocoa object. You have to pass them to labeled parameters – for example, you might define a for parameter, so you can say posix from url for anURL.
BridgePlus is a good example of this:
use AppleScript version "2.4"
use framework "Foundation"
use scripting additions
use libVariable : script "BridgePlus" version "1.3.2"
set aURL to Cocoaify (choose file)
set aFile to ASify from aURL
Notice the use of the from parameter where the URL is passed.