Previous Up Next

4.6.5  Incrementing variables

You can increase the value of a variable a by 4, for example, with

a := a + 4

If beforehand a were equal to 4, it would now be equal to 8. A shorthand way of doing this is with the += operator;

a += 4

will also increase the value of a by 4.

Similar shorthands exist for subtraction, multiplication and division. If a is equal to 8 and you enter

a -= 2

then a will be equal to 6. If you follow this with

a *= 3

then a will be equal to 18, and finally

a /= 9

will end with a equal to 2.


Previous Up Next