# 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="/files/Qu6uINOHm8vu7xITFBEJ" 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="/files/SXmM8bGauUjvWhtpjs4p" 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


---

# Agent Instructions: 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:

```
GET https://docs.uniot.io/platform/sandbox/visual-editor/functions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
