Team LiB   Previous Section   Next Section
-

Syntax

set aNum to 10 - 3.14

Return value

An integer if the left-hand operator is an integer and the right-hand operand is either an integer or can evaluate to a whole number (for example, 3.0 can evaluate to 3); a real if either operand is a real. If the left-hand operator is a date, then the result is of class date.

Description

This operator subtracts one operand from another or makes a number negative if there is only one operand. This operator can also be used to subtract time from dates, either in the form of an integer (representing seconds) or the constants minutes, hours, days, and weeks. The minus (-) symbol is also used in AppleScript to denote small real numbers, as in 1.0E-9 (this number is 0.000000001; see the description of the real value type in Chapter 3). AppleScript does not provide anything like a -- operator. The following is an example statement for decrementing a numerical variable in AppleScript:

set aNum to aNum - 1.

Here are some examples of subtracting time from dates.

Examples

set mydate to (date "Saturday, January 1, 2000 12:00:00 AM") - 1000 

(* subtracts one thousand seconds from the date *)



set mydate to (date "Saturday, January 1, 2000 12:00:00 AM") - (30 *¬ days)

(* subtracts 30 days from the date (you can also use the constants minutes, 

hours, days, or weeks) *)
    Team LiB   Previous Section   Next Section