inc()

Increments the given value by 1. If the first parameter is None or not a finite number, it resets to the third parameter. If the result exceeds the second parameter, it resets to the third parameter.

Syntax

inc(value, max, reset)

Parameters

Parameter Type Description
value Number/None Value to increment (None or invalid becomes reset).
max Number Maximum limit before resetting.
reset Number Value to reset to if None/invalid or limit exceeded.

Return Value

Examples

// If 'result' is NaN or None, it becomes reset (0).
result = nan();                // returns ---
result = inc(result, 3, 0);    // returns 0
result = inc(result, 3, 0);    // returns 1
result = inc(result, 3, 0);    // returns 2
result = inc(result, 3, 0);    // returns 3
result = inc(result, 3, 0);    // returns 0

See also

inc
dec