> For the complete documentation index, see [llms.txt](https://docs.flatredball.com/flatredball/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.flatredball.com/flatredball/glue-reference/states/tunneling-category-variables.md).

# Tunneling Category Variables

### Introduction

State categories automatically create variables in Screens and Entities through generated code. These generated variables can also be accessed in the FRB editor so they can be set on instances, or to assign change events.

### Example - Tunneling a Category

For this example, consider an Entity named StateEntity which has a SizeCategory with three states: Small, Medium, and Large.

<figure><img src="https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2FT0nctmuPC8ImyrQ0teny%2Fimage.png?alt=media&amp;token=9cc59487-0535-4424-b2a5-afd8c5d9f038" alt=""><figcaption><p>Entity with a SizeCategory</p></figcaption></figure>

This entity generates a variable called CurrentSizeCategoryState which can be accessed in code, as shown in the following code block:

```csharp
private void CustomInitialize()
{
    this.CurrentSizeCategoryState = SizeCategory.Large;
}
```

The CurrentSizeCategoryState can be tunneled on the entity which can be useful in a number of situations:

1. To set a default state for the entity
2. To set the state per-instance in the FRB Editor
3. To create events which is raised whenever a state is set to perform custom logic

To tunnel into a variable, drag+drop the category on the Variables folder.

<figure><img src="https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2F2FKySV40DIUX3mVNGSxn%2F31_10%2028%2017.gif?alt=media&amp;token=47d23eee-f610-486f-9b9c-6732c36b9ba9" alt=""><figcaption><p>Tunneling to the CurrentSizeCategoryState</p></figcaption></figure>

The tunneled variable now behaves like any other variable. For example, an event can be added to the variable which is raised whenever the SizeCategory changes.

<figure><img src="https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2FadiKP3vvFIB0XoJAG0ON%2F31_10%2031%2034.gif?alt=media&amp;token=9a555df0-64b5-4cce-8995-ba6d42b37490" alt=""><figcaption><p>Adding an Event for tunneled category variables</p></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.flatredball.com/flatredball/glue-reference/states/tunneling-category-variables.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
