Inc, Incr Command

Purpose

Increments a numeric variable.

Syntax

Inc v

Incr v [, n = 1]

v:numeric variable
n:numeric exp

Description

Inc v increments the variable v by 1.

Incr v, n increments the variable v by n (default 1).

Example

OpenW # 1

Local x = 2.7

Inc x

Print x    // Prints 3.7

Incr x, 2.5

Print x    // Prints 6.2

Remarks

Although Inc can be used with any numeric variable, the usage of integer variables is recommended in order to achieve the maximum optimization for speed. Alternatives to Inc are:

x = x + 1

x := x + 1

x += 1

x++

Sub x, -1

Add x, 1

When integer variables are used Inc doesn't test for overflow!

See Also

Add, Sub, Dec, Succ, Pred, ++, --, +=, -=

{Created by Sjouke Hamstra; Last updated: 10/10/2014 by James Gaite}