Command: INCRBY

Purpose: Increments by a specified amount the value of a specified array reference. This operation is atomic. If the array reference does not exist, it is created with a value of the specified amount. The new incremented value is returned.

Note that no pre-declaration of either the array name or its subscripting structure is required. Creation of array records is totally dynamic.

Arguments:

Argument No Description
1 The array node to be incremented. This takes the format:
   arrayRef[subscr1,subscr2,..etc]
You may specify no subscripts at all, in which case the top-level node is incremented,eg:
   arrayRef
Incrementing the first level of subscripting would look like:
   arrayRef[1]
Incrementing the second level of subscripting would look like:
   arrayRef[1,"aaa"]

Note that subscripts can be numeric or text. Text subscripts must be wrapped in double quote (") characters. Quoting of numeric subscripts is optional.
2 The amount by which the node should be incremented

Response

Single-line integer response

Server: :[new incremented value]

Examples

If test1["a","b"] does not yet exist:

Client: INCR test1["a","b"] 12
Server: :12

If the command is repeated:

Client: INCR test1["a","b"] 12
Server: :24

We can confirm the new value of test1["a","b"]:

Client: GET test1["a","b"]
Server: $2
Server: 24

For those familiar with the native language of GT.M and Caché systems, the above two examples are the equivalent of:

write $increment(^test1("a","b"),12)