An AppleScript makes use of variables, whose name can be any alphanumeric string. Variables may store quantities of various types, that AppleScript calls classes. AppleScript defines several data types, which include the following.
- string: stores a string of characters of unlimited length. You define a string by bracketing a quantity between double-quotes:
set myString to "hello world"
You must escape the double-quote and the backslash with backslash.
set myString to "escape \" and \\ with \\"
AppleScript defines several constants of class string: return, space and tab.
- boolean - true or false
- integer - stores integers in the range -536870912 .. 536870911
- real - stores (in double-precision) a real number in the range ±10^308.
AppleScript defines one constant real: pi.
- date - stores a date.
- list - stores a list of any quantities. You define a list by bracketing its items between braces.
set the_list to {pi, 3.14, 3, "3.14", {"e", 2.718}}
item 4 of the_list
-- "3.14"
- record - stores a list of key-value pairs.
set the_record to {name: "untitled", bounds: {44, 54, 689, 504}}
bounds of the_record
-- {44, 54, 689, 504}
|