$Increment()

Atomically adds (increments) a global variable by a numeric value. Note that increment is atomic, but the evaluation of the expression is not, unless inside a transaction (TStart/TCommit). The function also works on local variables, but has less benefit for locals as it does not (need to) provide ACID behavior.

The format of the $INCREMENT function is:

$INCREMENT(glvn[,numexpr])

Examples of $INCREMENT()

Example:

GTM>set i=1
GTM>write $increment(i)
2
GTM>write $increment(i)
3
GTM>write $increment(i)
4
GTM>write $increment(i)
5
GTM>write i
5
GTM>write $increment(i,-2)
3
GTM>write i
3
GTM>

This example increments the value of i by 1 and at the end decrements it by 2. Note that the default value for incrementing a variable is 1.