Increment
Synopsis
Increment(varname[,change])
Arguments
varname | The name of the variable to be incremented (or decremented). |
change | Optional — A numeric that specifies by how much the value should be incremented. The value of change can be negative for decrements. This value can be a fractional number. If specified as 0 (zero), no increment or decrement occurs. If not specified, varname is incremented by 1. |
Description
The virtual machine ensures that during the increment the variable is locked and after the increment unlocked. Because of the atomic nature of this function, this operation is very efficient especially in network environments.
Examples
The following example demonstrates the use of the Increment function:
^PersonRecords = 1000
NewPersId = Increment(^PersonRecords)
Println NewPersId 'prints 1001
NewPersId = Increment(^PersonRecords, 10)
Println NewPersId 'prints 1011
The following example demonstrates the use of the Increment function to decrement a number:
countdown = 10
While countdown > 0
Println countdown
countdown = Increment(countdown,-1)
Wend
Println "Blast off!"
The following example demonstrates the use of the Increment function with a fractional value to represent successive sevenths of a circle:
angle = 0
sevenths = 51.428572
While angle < 360
angle = Increment(angle,sevenths)
Println angle," degrees"
Wend