# Data Write Local

Write arbitrary data to a local storage area (allows looped workflows). This block stores the incoming value under a user-defined key so other blocks can retrieve it later. Note: this approach does not guarantee strict data flow ordering—use it when you need a simple shared storage or to break direct flow dependencies.

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

`Generic` — Input socket. Accepts any type of data to be stored.

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

This block does not have outputs.

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

`Data Key` — Enter a string that identifies where the input will be saved in local storage. Use descriptive, unique keys to avoid accidental overwrites.

(hint) Keys are treated as plain text names. Empty or duplicate keys may overwrite existing entries.

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

* Simple local storage: Save any incoming value under a named key so it can be read elsewhere in the scenario.
* Loop-friendly: Useful when you need to pass values around in systems that require indirect referencing (e.g., feedback loops).
* Lightweight and UI-driven: Key is set from the block interface, no extra configuration needed.

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

When the block runs, it checks the input socket. If a value is present, the block saves that value into the scenario's local storage under the string provided in the `Data Key` control. The saved value remains available until another write replaces it or the scenario ends. Because this storage is separate from the direct flow between blocks, timing and sequence guarantees are not enforced.

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

1. Enter a clear `Data Key` name (for example: "current\_count" or "last\_frame\_time").
2. Connect a producer block to the `Generic` input and run the scenario.
3. Other blocks can retrieve the saved value by reading the same key (use a local read block).

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

* Combine with `Data Read Local` to fetch the value later in the same scenario (useful for simple loops or passing metadata).
* Use with `Subsystem Loop` when you need to store intermediate results inside iterative flows.
* Use `Data Memory` to freeze or gate values you write, preventing unintended updates.
* Pair with `Is None` or `Debug Input` to verify whether a value was stored before attempting to read it.
* For logging or exporting stored records, read the key and feed the result to `Data to JSON`, `CSV Export`, or `Image Logger` as appropriate.
* To share data across separate scenarios or machines, use `Data Write Global` / `Data Read Global` instead of local write/read.

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

* No value appears when reading the key: verify the producing block actually sends data to the `Generic` input and that the `Data Key` text exactly matches the one used by the reader.
* Unexpected overwrite: ensure you use unique, descriptive keys. Consider adding a prefix (like board name or timestamp) if multiple parts of the scenario write similar values.
* Race conditions or inconsistent timing: remember local storage does not enforce data flow integrity. If strict ordering is required, prefer direct connections or synchronize via flow-control blocks.
