# counter

Counters are stored on disk, and are available from one import session to the next.

### counter(name)

Deletes the counter referred to by the name argument

### counter(name, increment)

Creates a new counter or increments existing counter by amount specified in the increment argument

### counter(name, increment, start)

Creates a new counter referred to by the name argument with a value determined by the start argument and increments it by the value determined by the increment value

## Arguments

Argument | Data Type | Description
name | string | name by which a counter is referred to
increment | number | amount by which the counter is to be incremented by
start | number | initial value of counter

## Returns

A counter with a required start value that is incremented by a required value

## Description

counter() is used to increment and store a number value

counter() values can be stored in between sessions. This means that the final value of a counter after one import session can be saved and used in further import sessions.

The start counter value can only be set once. This is done on creation of a new counter. Once a counter has been created, the inclusion of a value for the start argument will have no effect on current or future values.

If the only argument supplied is the name of a current counter then this counter will be deleted.

Every time the counter() function is called then the counter will be incremented by the value of the increment argument. The counter will be updated with the increment value every time the grid showing its current value is refreshed.

The increment value of the counter can be updated at any time - it is not restricted to the increment value provided at creation of the counter.

## Examples

Assume that these examples are performed in the same order that they are listed

Example | Returns | Description
counter("test", 1, 100) | 100 | This example assumes that the counter "test" has not previously been created. It returns the start value as the first value
counter("test", 2) | 102 | Since the counter had been previously created (last example) this implementation will increment the value now held in the "test" counter by 2
counter("test") | deleted | Provides the error message indicating the
counter("test", 5) | 0 | Unless a start argument is specified, new counters will always begin at 0. Unless changed, all subsequent calls to this counter will be incremented by five

## See Also

recno(), sesstr(), sesnun(), sesbool(), recstr(), recnumb(), recbool()