Online Book Reader

Home Category

AppleScript_ The Definitive Guide - Matt Neuburg [147]

By Root 1481 0

Strings

Name

return

Synopsis

"\r"

"\r"

Macintosh line-break character. There does not seem to be any conflict with the keyword return (see "Returned Value" in Chapter 9). The only place where a conflict could occur is when return is the first word of a line. The rule in that situation seems to be that if return is followed by an operator, it can't be the keyword, so it must be this property.

Example

"This is a line." & return & "This is another line."

Name

tab

Synopsis

"\t"

"\t"

Tab character.

Example

"an item" & tab & "another item"

Name

quote

Synopsis

"\""

"\""

Quote character. (This is new in Tiger.)

Example

quote & "This is cool," & quote & " said Tom frigidly."

Name

space

Synopsis

" "

" "

Space character.

Example

"word" & space & "otherWord"

Name

text item delimiters

Synopsis

"" (the empty string)

"" (the empty string)

The text item delimiters global property has two uses: it is used to split a string into its text item elements (see "String" in Chapter 13), and it is used to join list items when a list is coerced to a string (see "List Coercions" in Chapter 14). In theory it is a list of strings, but in fact it can be set to a string, and if it is a list, only the first item of the list matters.

Example

set text item delimiters to ":"

text item 1 of (path to system folder as string)

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).

Name

pi

Synopsis

3.14159265359

3.14159265359

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

Example

set area to pi * (radius ^ 2)

Name

minutes

Synopsis

60

60

The number of seconds in a minute.

Example

(current date) + 30 * minutes -- half an hour from now

Name

hours

Synopsis

3600

3600

The number of seconds in an hour.

Example

(current date) + 2 * hours -- two hours from now

Name

days

Synopsis

86400

86400

The number of seconds in a day.

Example

(current date) + 2 * days -- two days from now

Name

weeks

Synopsis

604800

604800

The number of seconds in a week.

Example

(current date) + 2 * weeks -- two weeks from now

Miscellaneous

Name

version

Synopsis

"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

Return Main Page Previous Page Next Page

®Online Book Reader