By Alvin Alexander. Last updated: August 10, 2018
I showed some basic AppleScript boolean-oriented syntax like this in another post:
set a to true if a then display dialog a end if
That code doesn't do too much, especially because you know the variable a
is set to true
, but it becomes a little more helpful when you don't know if a
is true or false:
if a then -- do something really important here end if
You can perform other if/then checks based on numerical tests, like this:
set balance to 0 if balance <= 0 then display dialog "No money left in the bank account" end if
Finally, you can combine boolean tests using syntax like this:
set checkingBalance to 0 set savingsBalance to 0 if checkingBalance <= 0 and savingsBalance <= 0 then display dialog "Yikes!" end if