> 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/functions.md).

# Functions

Functions let you organize code into reusable blocks. Create custom functions with parameters and return values to break down complex logic into manageable, reusable components.

## function definition

<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-b3668b49a450e50b27edb69a2c9afe722d4f0646%2Ffunctions_template.png?alt=media" alt=""><figcaption></figcaption></figure></div>

Defines a new function that can be called from anywhere in your script. Click the gear icon to add parameters and configure the return value.

**Configuration:**

* **Function Name**: A unique identifier for your function
* **Parameters** (Optional): Input values the function accepts
* **Return** (Optional): Enable to make the function return a value

**Example uses**: Calculating averages, converting units, validating sensor ranges, or any logic you use multiple times.

## function call

<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-2e56fcfa082df221fd37ff740ce8ed637891a94e%2Ffunctions_call.png?alt=media" alt=""><figcaption></figcaption></figure></div>

Executes a previously defined function. Provide values for any parameters the function expects.

**Parameters:**

* **Function**: Select which function to call
* **Arguments**: Values matching the function's parameter list

**Returns:**

* **Any**: The function's return value if configured, otherwise performs actions without returning a value
