[About The Guide]
++<idVar> (prefix increment)
<idVar>++ (postfix increment)
<idVar> is any valid CA-Clipper identifier including a field
variable. If <idVar> is a field, it must either be prefaced with an
alias or declared with the FIELD statement.
The prefix increment can only be performed on an initialized value of
numeric or date data type.
The increment operator (++) increases the value of its operand by one.
This operator adds one to the value of <idVar> and assigns the new value
The ++ operator can appear before or after <idVar>. Specifying the
operator before <idVar> increments and assigns the value before <idVar>
is used. This is called prefix notation, and it is the most common
usage. Specifying the operator after <idVar>, postfix notation,
increments and assigns the value after <idVar> is used. Stated
differently, postfix notation delays the assignment portion of the
operation until the rest of the expression is evaluated, and prefix
notation gives the assignment precedence over all other operations in
If the reference to <idVar> is ambiguous (i.e., not declared at compile
time and not explicitly qualified with an alias), <idVar> is always
assumed to be MEMVAR. You can assign field variables by declaring the
field variable name in a FIELD statement or referring to the field name
prefaced by the FIELD-> alias or the name of the work area.
. This code uses the prefix increment operator in an assignment
statement. Therefore, both variables have the same value when
nValue := 0
nNewValue := ++nValue
? nNewValue // Result: 1
? nValue // Result: 1
. In this example, the postfix increment operator increases the
first operand of the multiplication operation by one, making its
value 11; however, the assignment of this new value to the nValue
variable will not take place until the entire expression is
evaluated. Therefore, its value is still 10 when the multiplication
operation occurs, and the result of 11 * 10 is 110. Finally, when
nValue is queried again after the expression is evaluated, the
postfix increment assignment is reflected in its new value, 11.
nValue := 10
? nValue++ * nValue // Result: 110
? nValue // Result: 11
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson