> For the complete documentation index, see [llms.txt](https://docs.heisenware.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.heisenware.com/~/changes/Q625pQNc0nXqVGPtyjAY/building-apps/data-processing/utilities/counter.md).

# Counter

The counter counts up or down from zero or a preset number every time the corresponding functions are triggered. A counter can also count into the negative.

To quickly start with counters:

1. Find the `Functions` panel on the left-hand side of the screen.
2. Expand `Utilities` and then `Counter.`
3. Create a counter instance with the [`create`](#create) function.
4. Expand the instance that appeared in the panel and get started with using the timer.

Use the [`create`](#create) and [`delete`](#delete) functions to manage the existing timers. Existing timers can be seen in the functions panel on the left under `Timer`. Yellow ones are not instantiated and green ones are ready for use.

## Creating a counter

To `create` a counter:

1. Insert a counter name in the yellow field.
2. Optionally insert a number for the initial state of the counter. (Only works if the counter is not yet instantiated.)
3. Click the trigger field to create an instance of the counter. You should see the counter in the functions panel go from yellow to green.

<div align="center"><figure><img src="https://3495989837-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FE5Ketpww1s7TauSAJrJ8%2Fuploads%2FyEqMGcv8T9xbwZbiBGiX%2Fimage.png?alt=media&amp;token=ffc22a36-c4c9-4a49-9f66-ff5f966cd9a9" alt=""><figcaption><p>Creating a counter with initial state of 55</p></figcaption></figure></div>

## Deleting a counter

To `delete` a counter:

1. Insert the name of the existing counter you want to delete in the yellow field.
2. Click the trigger field.

<div align="center"><figure><img src="https://3495989837-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FE5Ketpww1s7TauSAJrJ8%2Fuploads%2FDzl363OhBrzAfXPRFAZZ%2Fimage.png?alt=media&amp;token=dc9b4702-3fdf-4da4-890f-51be9946d1ad" alt="" width="563"><figcaption><p>Deleting a counter instance</p></figcaption></figure></div>

{% hint style="info" %}
The instance in the functions panel will turn yellow again, until the yellow field of the `create` function is cleared, or the `create` function is deleted from the board.
{% endhint %}

## Counter functions

To utilize counters, you can find functions tied to each instance when you expand the instance.

<div align="center"><figure><img src="https://3495989837-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FE5Ketpww1s7TauSAJrJ8%2Fuploads%2FKByuJ8aD5761oAx7wMbF%2Fimage.png?alt=media&amp;token=e2829763-0a1d-4ca1-bcd3-55881cfe01a3" alt="" width="299"><figcaption><p>Location of counter instances</p></figcaption></figure></div>

### Incrementing a counter

Triggering the `increment` function increases the counter by `1`.

<div align="center"><figure><img src="https://3495989837-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FE5Ketpww1s7TauSAJrJ8%2Fuploads%2FixKxeX8gfSw2geA09aUt%2Fimage.png?alt=media&amp;token=83d7393e-1d73-4d13-8b14-f5b5698b0e7b" alt="" width="563"><figcaption><p>Incrementing the counter</p></figcaption></figure></div>

### Decrementing a counter

Triggering the `decrement` function decreases the counter by `1`.

<div align="center"><figure><img src="https://3495989837-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FE5Ketpww1s7TauSAJrJ8%2Fuploads%2Ffnvb1q70przNaFXRRZMI%2Fimage.png?alt=media&amp;token=da14d159-57e6-4578-9f4f-5055e0dae4d0" alt="" width="563"><figcaption><p>Decrementing the counter</p></figcaption></figure></div>

### Resetting a counter

With `reset` you can set the counter to `0` or a new specified state. The input field has initial greyed out in it, because in the future reset should reset the function to the initial state. As such, please always enter a number for now.

1. Insert or link a value in the input field.
2. Trigger the function.

<div align="center"><figure><img src="https://3495989837-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FE5Ketpww1s7TauSAJrJ8%2Fuploads%2Fk9bUDUvvynrd4IVYNlD4%2Fimage.png?alt=media&amp;token=ef3aa792-7247-4f60-95d3-7e8a42910bef" alt="" width="563"><figcaption><p>Setting a new value for the counter</p></figcaption></figure></div>

### Getting the count

The `getCount` function returns the current count of the counter.

<div align="center"><figure><img src="https://3495989837-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FE5Ketpww1s7TauSAJrJ8%2Fuploads%2FIgvvgyKsrkHMhr4VEXH2%2Fimage.png?alt=media&amp;token=609f5672-098d-4dd7-8c8e-c60aef6e89d5" alt="" width="563"><figcaption><p>Getting the counter state</p></figcaption></figure></div>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.heisenware.com/~/changes/Q625pQNc0nXqVGPtyjAY/building-apps/data-processing/utilities/counter.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
