Chapter 3. Data Types
In Chapter 1, I touched
on data types, but now I will delve deeper! A data type describes how
a programming system stores data in memory, and it is similar to the
types used by other languages such as Java or Visual Basic.
AppleScript data types specify the type of value that a variable
stores (e.g., date, integer,
string, real) or that an
AppleScript command or scripting addition returns (see Appendix A). The data type that a variable stores
determines what the script can do with it afterward, such as perform
a math operation on an integer type or find out
the length property (the number of characters) of
a string
type.
This chapter only describes the built-in AppleScript data types; however, a variable could also store a reference to an object such as a file, a web URL, or a database record (see Chapter 1 and its discussion of Apple event objects). Table 3-1 lists the data types described in this chapter, which also includes the correct syntax to use when storing a certain data type in a variable and the other data types to which a variable can allowably be cast or coerced.
alias |
real |
boolean |
record |
class |
reference |
constant |
RGB color |
data |
string |
date |
styled Clipboard Text |
file specification |
styled Text |
integer |
text |
international Text |
Unicode text |
list |
unit of measurement classes |
number |
With some exceptions such as the date data type, you do not have to declare a data type when you declare a variable. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access