Command: DECRBY

Purpose: Decrements 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 decremented 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 decremented. This takes the format:
   arrayRef[subscr1,subscr2,..etc]
You may specify no subscripts at all, in which case the top-level node is decremented,eg:
   arrayRef
Decrementing the first level of subscripting would look like:
   arrayRef[1]
Decrementing 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 decremented

Response

Single-line integer response

Server: :[new decremented value]

Examples

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

Client: DECR test1["a","b"] 12
Server: :-12

If the command is repeated:

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

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

Client: GET test1["a","b"]
Server: $3
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)