INCR
WSupported on Windows
|
USupported on Unix
|
VSupported on OpenVMS
|
NSupported in Synergy .NET
|
INCR variable
Arguments
variable
A variable whose value is to be incremented by 1. (n)
Discussion
The INCR statement increases the value of a specified variable by 1.
If the incremented value of variable overflows its size, variable is set to its zero representation. For example, the following code fragment increments dvar from 9 to 0, because dvar is a d1 field instead of a d2.
record dvar ,d1 ,9 proc incr dvar
It is more efficient to use the INCR statement than to add 1 to a variable. |
With integer values, if the variable has the maximum value for its size, the following statements has different results: incr ivar ivar = ivar + 1 In the example below, i1 = i1 + 1 is equivalent to i1 = 128 which results in -128. See Moving integer data to an integer destination for more information. record i1 ,i1, 127 ;Max value for an i1 field proc incr i1 ;Result is 0 i1 = 127 i1 = i1 + 1 ;Result is -128 The following statement “rolls” the value to zero. Doing so maintains consistency with the behavior of decimal variables, which may be used as counters and may depend on this property. incr i1 |
See also
DECR statement
Examples
record ifld ,i2 ,20 dfld ,d4 ,20 idfld ,d4.2 ,20.00 proc ;Incremented result is: incr ifld ;21 incr dfld ;21 incr idfld ;21.00