> For the complete documentation index, see [llms.txt](https://docs.uniot.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.uniot.io/platform/sandbox/visual-editor/variables.md).

# Variables

Variables store and manage data in your scripts. Use variables to track changing values like sensor readings, counters, states, or calculated results.

{% hint style="info" %}
Create variables through the Variables section in the toolbox before using them. Variable names are case-sensitive - choose meaningful names to make your code easier to understand.
{% endhint %}

## set

<div align="left"><figure><img src="https://1776027180-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsSE1iwGRAGqUrb5YXfFa%2Fuploads%2Fgit-blob-f6404685a8acf84e53b61482722d21250a8d36b6%2Fvariables_set.svg?alt=media" alt=""><figcaption></figcaption></figure></div>

Assigns a value to a variable. If the variable doesn't exist, it's created automatically.

**Parameters:**

* **Variable**: Select from the dropdown or create a new variable
* **Value** (Any): The value to store

**Example:**

<figure><img src="https://1776027180-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsSE1iwGRAGqUrb5YXfFa%2Fuploads%2Fgit-blob-677227ca5dfc5b5e2de89b236659f5097e196d76%2Fvariables_set_example.svg?alt=media" alt=""><figcaption><p>Setting variables</p></figcaption></figure>

## get

<div align="left"><figure><img src="https://1776027180-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsSE1iwGRAGqUrb5YXfFa%2Fuploads%2Fgit-blob-1d6040b99d21d9311e89ae70688c569cf627b4b9%2Fvariables_get.svg?alt=media" alt=""><figcaption></figcaption></figure></div>

Retrieves the current value stored in a variable.

**Parameters:**

* **Variable**: Select which variable to read

**Returns:**

* **Any**: The current value of the variable

**Example:**

<figure><img src="https://1776027180-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsSE1iwGRAGqUrb5YXfFa%2Fuploads%2Fgit-blob-ff75062f70a21082eed18fb7dfd29d9517082e46%2Fvariables_get_example.svg?alt=media" alt=""><figcaption><p>Getting variable values</p></figcaption></figure>

## change

<div align="left"><figure><img src="https://1776027180-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsSE1iwGRAGqUrb5YXfFa%2Fuploads%2Fgit-blob-4cd06d13a7b4477d6f43a7efefcadfb72b12eace%2Fvariables_change.svg?alt=media" alt=""><figcaption></figcaption></figure></div>

Increments or decrements a numeric variable by adding a value to it. Use negative values to subtract.

**Parameters:**

* **Variable**: Select which variable to modify
* **Value** (Number): The amount to add (use negative for subtraction)

**Example:**

<figure><img src="https://1776027180-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsSE1iwGRAGqUrb5YXfFa%2Fuploads%2Fgit-blob-60a9a26c5283e8e2ae2204081a486301eca22b60%2Fvariables_change_example.svg?alt=media" alt=""><figcaption><p>Modifying variables</p></figcaption></figure>

## Managing Variables

<div align="left"><figure><img src="https://1776027180-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsSE1iwGRAGqUrb5YXfFa%2Fuploads%2Fgit-blob-b77bc24a224734ad3f937513c4daaebc23cb1f86%2Fvariables_dropdown.png?alt=media" alt="" width="233"><figcaption></figcaption></figure></div>

The variable dropdown menu in each block provides options to:

* **Select** existing variables from your script
* **Rename** the selected variable (updates all references)
* **Delete** the selected variable (removes from all blocks)

{% hint style="warning" %}
Renaming or deleting a variable affects **all blocks** that use it. Be careful when modifying variables used in multiple places.
{% endhint %}
