add

Adds a number to a container and places the resulting value in the container.

# Metadata

Platforms: desktop, server OS: mac, windows, linux, ios, android Introduced: 1.0 Security:

# Syntax

add number to [chunk of] container

# Params

- number : An expression that evaluates to a number. - chunk : A chunk expression specifying a portion of the container. - container : A field, button, or variable, or the message box. - array : An array variable each of whose elements is a number. - arrayContainer : An array variable each of whose elements is a number.

# Examples

add 7 to field 1

local tSummaryOfInventory add field "New" to tSummaryOfInventory

local qty, price, tOrder add (qty * price) to last line of tOrder

# Assume the following handler in a button, along with # field "list1" and field "list2" each containing # an equal number of return-separated numerals. # Field "added" is empty. on mouseUp local tNumList1, tNumList2 put fld "list1" into tNumList1 put fld "list2" into tNumList2 split tNumList1 by return split tNumList2 by return add tNumList2 to tNumList1 combine tNumList1 by row put tNumList1 into fld "added" end mouseUp

# Description

Use the add command to add a number to a container or a portion of a container, or to add two arrays containing numbers.

The contents of the container (or the chunk of the container) must be a number or an expression that evaluates to a number.

If a number is added to an arrayContainer, the number is added to each element. If an array is added to an arrayContainer, both arrays must have the same number of elements and the same dimension, and each element in the array is added to the corresponding element of the arrayContainer.

If the container or an element of the arrayContainer is empty, the add command treats its contents as zero. If container is a field or button, the format of the sum is determined by the numberFormat property.

If a math operation on finite inputs produces a non-finite output, an execution error is thrown. See math operations for more information.

# Tags

# See

- **keyword:** element - **property:** numberFormat - **command:** combine, multiply, split, union - **function:** sum, value - **glossary:** array, command, container, element, evaluate, expression, format, property, math operation - **object:** button, field