AppleScript tip: basic math operations

By Alvin J. Alexander, devdaily.com

To add a few numbers together just use the normal set syntax and the + operator, like this:

set one to 1
set two to 2
set answer to one + two
display dialog answer

That example displays the number 3. Here's a similar example, but this time using subtraction:

set one to 1
set two to 2
set answer to two - one
display dialog answer

That will display the number 1. Multiplication looks like this:

set one to 1
set two to 2
set answer to two * two * two * two
display dialog answer

and division looks like this:

set one to 1
set two to 2
set answer to one / two
display dialog answer

devdaily logo