Yeah, I can’t do this. It’s non-obvious to me how it translates until I actually stumble upon the correct thing.
Yeah, I can’t do this. It’s non-obvious to me how it translates until I actually stumble upon the correct thing.
It certainly reads nicer to non-programmers, but I feel like writing it requires just as much learning as any more "traditional" scripting language, so I'm not really sure what the benefit is.
I really like Applescript. I agree that it's harder to write, and especially harder to write well, because functional Applescript won't necessarily come out as english sentences, if you aren't careful to construct it the right way.
But the enhanced readability makes it worthwhile. I love that I can look at my own Applescript code and just read what it's doing in english.
I actually wish I could do more with Applescript than just Mac scripting. I've been thinking for a few years now that I ought to play around with Hypercard, but PowerPC emulators are a pain to get running. There's a modern clone called SuperCard, but it costs $200...
P.S. The "open dictionary" option built into the Script Editor is helpful for finding the right "incantation".
Read-only, write-never?
;)
Back when appscript was still a thing I hacked together a quick-n-dirty AppleScript-command-to-Python/Ruby/ObjC translator app which appscript users absolutely adored, plus it greatly reduced the number of “How do I…” support questions because, more often than not, users already had a working example in AppleScript which they could just run through the translator to get the answer for themselves.
Needless to say, Sal Soghoian completely ignored my expert recommendation for this killer feature which could be implemented in a day, choosing instead to dump JXA and its few hapless users down the same black hole of nothingness as all his other product failures. PEBKAC. Not Invented Here. So it goes.
--
[edited to add]
Just d/led the JavaScriptOSA zip from the appscript project page on SourceForge, and the bundled JABDemo.app still works. It’s not codesigned so you’ll have to right-click the app to Open it, overriding the security warnings, but it still works even on 10.15 (caveat any bugs in the underlying JavaScript Apple event bridge, of which there were a few, plus the endless string of permission requests whenever you try to control another app). Example:
Original AppleScript commands:
tell app "textedit" to get name of document 1
tell app "finder" to count every folder of home whose name begins with "D"
Generated JavaScript equivalents: app("TextEdit").documents.at(1).name.get()
app("Finder").home.folders.where(its.name.beginsWith("D")).count({each: k.item})
I mean, I wrote the thing and even to me years later it’s still like freaking voodoo! :)