This post is going to cover some observations about using AppleScript.
This is going to be a fairly informal post since it's my thoughts and observations.
Variables... where are they declared?
I was a bit confused because variables are not declared any one.
In Swift, variables are always declared before they are used.
var name: String
// or use type inferencing
var name = "Maegan"
In AppleScript to declare a variable the command is set var_name to "var_value"
. I realized I wanted all my variables to be declared in a central place while working in AppleScript, but I couldn't really do that.
AppleScript is very human readable
AppleScript is completely human readable. A lot of the commands are made to be read. Here are some examples:
- To declare a loop, it is a
repeat
command. - To break out of the loop, it is a
exit repeat
command. - To check if something is not equal
if varA is not "20" then
-- Do something here
else
-- Do something else
end if
- To make an application do something, use the
tell
command
To me, these are very human readable.
There are no brackets!
While the commands are human readable, the nesting of code is not as human readable. There are no brackets and ScriptEditor.app does not have guides so the nesting can be hard to follow.
THE POWER IS THERE
Lots of Mac apps support AppleScript. I have created a Keynote presentation that counts down from 1 hour all the way to 00:00:00, about 3300 slides, in maybe 15 minutes. I made a show control setup that fades down and pauses Spotify and also another one that fades up, skips to the next track, and plays the track at the same time.
The end
Those were my quick observations. If you have any tips about AppleScript, let me know in the comments!
If you enjoy my posts, please consider sharing it or Buying me a Coffee!
Latest comments (1)
I agree with a lot of this. Since it doesn’t follow a lot of programming language conventions it’s hard to remember how to write the script.