Inform 7 Home Page / Documentation


§8.12. Increasing and decreasing

Once we begin to deal with named values (or table entries, list entries or other ways to describe places where values are kept), we find that we often want to change them. We could if we wanted always use "now" for this, but it can be a little clumsily worded if we want to increase or decrease something:

now the score is the score plus six;

Because of that, we have some convenient abbreviations which have the advantage that the value being changed only has to be named once:

increase (a stored value) by (value)

This phrase increases the variable, table entry, list entry, or property by the given amount, which must be of a compatible kind. Example:

increase the score by 8;
increase the time of day by 5 minutes;

decrease (a stored value) by (value)

This phrase decreases the variable, table entry, list entry, or property by the given amount, which must be of a compatible kind. Example:

decrease the score by 6;
decrease the carrying capacity of the player by 10;

An even greater abbreviation can be made when we are changing a number by 1 either way:

increment (a stored value)

This phrase increases the variable, table entry, list entry, or property by 1. Example:

increment the score;

decrement (a stored value)

This phrase decreases the variable, table entry, list entry, or property by 1. Example:

decrement the score;

"Increment" and "decrement" are traditional computing terms, though they have been used in engineering for at least a century and in finance for longer still.


arrow-up.png Start of Chapter 8: Change
arrow-left.png Back to §8.11. Now...
arrow-right.png Onward to §8.13. Checking on whereabouts