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.
The array node to be decremented. This takes the format:
You may specify no subscripts at all, in which case the top-level node is decremented,eg:
Decrementing the first level of subscripting would look like:
Decrementing the second level of subscripting would look like:
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|
Single-line integer response
Server: :[new decremented value]
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: