Flylib.com

Books Software

 
 
 

Section 16.2. Numbers


16.2. Numbers

The minutes property and its ilk are intended to help you convert to seconds. This is because date arithmetic uses seconds (see "Date" in Chapter 13 and "Arithmetic Operators" in Chapter 15).

pi

3.14159265359

3.14159265359

The ratio of a circle's circumference to its diameter.

Example

set area to pi * (radius ^ 2)

minutes

60

60

The number of seconds in a minute.

Example

(current date) + 30 * minutes --

half an hour from now


hours

3600

3600

The number of seconds in an hour.

Example

(current date) + 2 * hours --

two hours from now


days

86400

86400

The number of seconds in a day.

Example

(current date) + 2 * days --

two days from now


weeks

604800

604800

The number of seconds in a week.

Example

(current date) + 2 * weeks --

two weeks from now




16.3. Miscellaneous

version

"1.10.3"

"1.10.3"

The version of AppleScript. The name of this property is also the name of a class, and the appearance that its value is a string is an illusion; this value is actually a version, which is coerced to a string for display.

Example

display dialog AppleScript's version --

"1.10.3"

AppleScript's version as real --

1.1003




Chapter 17. Constants

A constant in AppleScript is a term that functions as a value. It isn't a variable, which is a name that has a value. A constant is a value. The fixed value of a constant will appear to you as the name of the constant. For example, the value of yes is yes ; it cannot be reduced to any other form (though a constant can be coerced to a string). You can use it as a value, but that's about all you can do with it. You cannot set the value of a constant; if you try, you'll get a compile-time error, "Access not allowed." You cannot create a variable whose name is that of a constant; if you try, you'll get a compile-time error, "Expected variable name or property but found application constant or consideration." The datatype (class) of a constant is usually constant ; but as we shall see, some of them are a class instead.

Behind the scenes, many constants are implemented as enumerations , meaning a set of fixed values (called enumerators ), any of which may occupy a certain syntactic slot. For example, the replacing clause of the store script command (see "Compiled Script Files as Script Objects" in Chapter 8) may consist of any of the constants yes , no , or ask . Nothing stops you, however, from supplying some other value, in which case it is up to the target to decide how it wants to respond. If you say replacing 42 in a store script command, the script will compile and run. If you try to set a date's weekday to yes , the script will compile but not run.

Applications are free to extend AppleScript's vocabulary by implementing constants of their own. For example, GraphicConverter can save an image file in many formats, and it needs a way to let you specify a format; it does this with some four dozen constants, such as PICT , TIFF , GIF , BMP , and JPEG . An application's dictionary will show you the constants that can be used in any connection with a given command. See "Enumerations" in Chapter 20.



true, false

Description

Boolean values. See "Boolean" in Chapter 13 and "Boolean Operators" in Chapter 15.

Example

open for access f write permission true