Commands

add

Supported By

Syntax

add number to container

Number yields an integer, a number, or a complex. Container yields a container containing an integer, a number, or a complex.

Examples

add 3 to it
add amount to total

Description

The add command adds the value of number to the value of container and leaves the result in container. The value in the container must be an integer, a number, or a complex and is replaced with the new value.

Script

The following example sums a line-delimited list of numbers and prints the result.

on printSum numberList
  put 0 into total
  repeat with count = 1 to the number of lines ¬
      in numberList
    add line count of numberList to total
  end repeat
  put total
end printSum

See Also

subtract, multiply, divide, +, sum