Incremental Integer Number Function

The incremental function \$Inc has two forms.
In the first form it has the following parameters:

1. (optional) Initial value*. Integer, default is 1.
2. (optional) Step*. Integer, default is 1.
3. (optional) Format. String, default is '{0}' for .net edition of the library, '%I64i' for Win32 and '%d' for Java editions.
4. (optional) Sequence border*, the function backs to the first value if the current value greater than this parameter. Integer. 0 is the default value that means "No cycle".
5. (optional) Reuse counter*. Integer, default is 1. How many times the engine should return each generated value.

* - the function call (like \$Pattern) is acceptable instead of constant value for: 'Initial value', 'Step', 'Cycle length' and 'Reuse counter'. Performance warning: it can work a few times slowly for some cases.

#### Examples

1. \$Inc() - same as \$Inc(1,1). Output: 1,2,3,4,5,6,7,8,9,...
2. \$Inc(10,5). Output: 10,15,20,25,30,35,...
3. \$Inc(0,-5,%d). Output: 0,-5,-10,-15,-20,-25,...
4. \$Inc(0,10,%04d,40,2). Output: 0000,0000,0010,0010,0020,0020,0030,0030,0040,0040,0000,0000,0010,0010,...
5. \$Inc(\$Pattern(@1), \$Vars(#step)) - use column #1 as a initial value and local variable '#step' as Step value.

In the second form the first parameter should be replaced to table name and column name. The function will use the next value after last found.
I.e. it will execute "select max(column) from table", add "step value" to retrieved number and use the result as the initial value.

#### Examples

1. \$Inc(Orders,OrderID)
2. \$Inc(Orders,OrderID,2,%04d)

Limitation: all integer parameters must be between -9223372036854775808 and 9223372036854775807