# Data Memory

This function block keeps a value in memory and optionally updates it when requested. It is useful for preserving the last known data across runs or for freezing a value until an explicit update is provided.

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

`Generic` General input data to store in memory. Can be any data type (numbers, text, image, lists, dictionaries, etc.).\
`Update Data` Boolean input that controls whether the incoming data should replace the stored value.

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

`Generic` The currently stored value. If never updated, this may be empty/None.

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

This block has no additional UI widgets. Behavior is controlled by the two sockets listed above.

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

* Persistent in-flow memory: holds a value across evaluations and only changes when `Update Data` is true.
* Accepts any data type on the `Generic` socket.
* Simple freeze/unfreeze mechanic: set `Update Data` to False to freeze the stored value, True to allow updates.

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

1. Feed the value you want to keep into the `Generic` input.
2. Toggle `Update Data` to True when you want the memory to accept the new input.
3. Set `Update Data` to False to freeze the stored value; the block will keep outputting that value until an update is allowed.

## 📊 Evaluation <a href="#evaluation" id="evaluation"></a>

On each evaluation the block checks the `Update Data` input. If True, it stores the current `Generic` input and outputs it. If False, it outputs the previously stored value unchanged.

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

* Use with `Is None` to detect missing inputs before writing into memory, keeping the stored value safe from accidental None overwrites.
* Pair with `Replace None` to provide fallback data when the input is empty, then control writes with `Update Data`.
* Combine with `Data Read Local` / `Data Write Local` or `Data Read Global` / `Data Write Global` for more persistent sharing between different parts of your flow.
* Use alongside `Debug Input` to log stored values during development and verify when memory updates happen.
* When processing batches, coordinate with `Batch Processing`, `Get Batch Size`, or `Batch Concatenation` to control whether memory should store whole batches or individual elements.
* For logging or export scenarios, feed the block output into `CSV Export`, `Image Logger`, or other export blocks to record the preserved data only when a confirmed update occurs.

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

* If output never changes, ensure the `Update Data` input is being set to True when you expect an update.
* If stored value becomes None unexpectedly, check upstream blocks for None outputs and consider using `Replace None` before writing to memory.
* If multiple areas of your flow require the same value, prefer the read/write local/global blocks to avoid duplication and ensure consistent updates.


---

# 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/data-operations/data-memory.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.
