# Data Write Global

This function block stores incoming data into a shared global storage accessible by other blocks in the same scenario. It is useful when you need to pass values across different parts of a scenario, create simple cross-flow communication, or implement loops that require shared state. Note that using global storage can introduce timing or integrity limitations — it does not guarantee strict data flow ordering.

## 📥 Inputs <a href="#inputs" id="inputs"></a>

`Generic` The data to be stored in the global storage under the chosen key.

## 📤 Outputs <a href="#outputs" id="outputs"></a>

This function block does not produce any outputs.

## 🕹️ Controls <a href="#controls" id="controls"></a>

`Key` A text field where you enter the name used to store the incoming data in global storage. Use a clear, unique key to avoid unintended overwrites.

## 🎯 Features <a href="#features" id="features"></a>

* Persistent cross-block storage within the running scenario, enabling sharing of values, images, lists, or any generic data type.
* Works well for creating communication points when direct socket connections are impractical (for example, when implementing loops).
* Simple write-only interface: when data is provided to the input, the block writes it to global storage under the chosen `Key`.
* Lightweight and fast for small amounts of data.

## ⚙️ Running mechanism <a href="#running-mechanism" id="running-mechanism"></a>

* When the block receives a value on the `Generic` input, it stores that value in the scenario's global storage using the text entered in the `Key` control.
* The block itself does not return a value; other blocks can retrieve the stored data by reading the same `Key` from global storage.
* Because global storage is shared, writes can overwrite previous values with the same key. Timing between writes and reads depends on the flow of the scenario.

## 📝 Usage Instructions <a href="#usage" id="usage"></a>

1. Enter a unique name into the `Key` control.
2. Provide the data you want to share into the `Generic` input.
3. Use a corresponding read block to access the stored data elsewhere in the scenario.

## 💡 Tips and Tricks <a href="#tips-and-tricks" id="tips-and-tricks"></a>

* Use `Data Read Global` to retrieve values written by this block in other parts of your scenario.
* For local-only communication inside a tight loop, prefer `Data Write Local` and `Data Read Local` to avoid broad shared-state side effects.
* To inspect what is being written during development, connect a `Debug Input` block or use `CSV Export` / `Data to JSON` to log content.
* When storing complex structured data (lists, dictionaries), consider converting it to a serializable format with `Data to JSON` before writing, and parse it after reading.
* If you need to save images or many frames, combine this block with `Image Logger` or `Multi Image Write` rather than keeping large image batches in global memory.
* Avoid key name collisions by adopting a naming convention (for example, prefixing with a module name or purpose).

## ✅ Best practices <a href="#best-practices" id="best-practices"></a>

* Choose descriptive keys and document them in your scenario so other users know what each key contains.
* Keep global writes minimal and infrequent for better predictability.
* If multiple writers may update the same key, design a handshake or versioning pattern (for example, write a timestamp or counter alongside the data) so readers can determine freshness.

## 🛠️ Troubleshooting <a href="#troubleshooting" id="troubleshooting"></a>

* If a reader cannot find expected data, confirm the exact `Key` text matches between writer and reader.
* If values appear stale or overwritten unexpectedly, check other parts of the scenario for writes to the same key and consider using local storage instead.
* If you encounter inconsistent behavior in loops, try restructuring the flow to read immediately after a write or use explicit flow-control blocks to synchronize operations.


---

# 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.augelab.com/function-blocks/data-logic/referencing/data-write-global.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.
