Unit Types and Coercions
(built-in)
This version introduces the concept of units of
measurement and some basic units. Applications or
scripting additions can extend these easily. The types
defined include:
- length
- area
- volume (liquid and solid)
- temperature
A complete list of specific types can be found in the
Help Center in the AppleScript section. (Note: the Help
Center claims AppleScript has support for quarts; this is
not the case.) Constants can be found in
<ASRegistry.h>
.
The basic manner of use in AppleScript scripts is by
coercion, e.g. "5 as inches". A value of one class can be
coerced into another similar class, such as "5 as feet as
inches", so long as both classes share a common unit type
(in this case, length, whose base unit is meters).
To compile the displayed results of a command that
returns a unit-type value, a global Get Data
handler
has been added to resolve the unit type object specifier and
coerce it to a value.