Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- CA-Clipper 5.3 . Guide To CA-Clipper - <b>++</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 ++
 Increment--unary                                (Mathematical)
------------------------------------------------------------------------------
 Syntax

     ++<idVar>         (prefix increment)
     <idVar>++         (postfix increment)

 Type

     Date, numeric

 Operands

     <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.

 Description

     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
     to <idVar>.

     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
     the expression.

     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.

 Examples

     .  This code uses the prefix increment operator in an assignment
        statement.  Therefore, both variables have the same value when
        queried:

        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


See Also: + -- := = (compound)

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson