3 ms·
One of the things I really like about Applescript is that, at least for simple tasks, the code reads as standard english. This isn't to say you can type anythin
by Wowfunhappy 8y ago
One of the things I really like about Applescript is that, at least for simple tasks, the code reads as standard english. This isn't to say you can type anything in english and Applescript will interpret it, just that the correct syntax also happens to form real sentences.
Here is how I tell QuickTime to play NPR:
set WNYCAddress to "http://www.wnyc.org/stream/wnyc-fm939/aac.pls"
tell application "QuickTime Player" to open URL WNYCAddress
Here is how to tell if the file you've highlighted in Finder is on a specific drive:
set theNameOfTheDrive to "Archive"
tell application "Finder" to set theSelectedFile to the target of the front Finder window as text
if theSelectedFile starts with theNameOfTheDrive then log "that file is on the right drive!"
Unfortunately, it all starts to break down when you get to more complicated stuff, but in the right situations it's kind of beautiful. I wish Apple had taken it a bit further...
- microtherion 8y agoWicked tongues have called AppleScript "Visual COBOL".
- Wowfunhappy 7y agoAre we just comparing any old-ish languages we don't like to COBOL now? Applescript has its problems but it's one of my favorite features in macOS. Maybe not the language itself, but the Apple Events capability. There's no equivalent in Windows other than AutoHotKey type stuff.
- microtherion 7y agoFor AppleScript, the analogy seemed apt, as both AppleScript and COBOL set out to design a syntax resembling conversational English more than a typical programming language would.
- Wowfunhappy 7y agoThank you, I've never actually seen COBOL code (presumably a good thing...)