# State Categories

### Introduction

State Categories can be thought of as folders for states. State Categories are used for a number of reasons:

* To organize similar states into categories
* To allow multiple states to be set at the same time (if not sharing variables between states)
* To create multiple state types for more expressive code (if not sharing variables between states)
* To enable including and excluding particular variables from assignment

State categories will appear as folders in the tree view, and can contain any number of States. &#x20;

<figure><img src="/files/YApy7XzbU0gOQF0jyTXq" alt=""><figcaption><p>Categorized states</p></figcaption></figure>

Note that categorized cannot be added inside of other categories.

### Adding a State Category

To add a state category:

1. Expand a Screen or Entity that you want to add a category to
2. Right-click on the States item
3. Select **Add State Category**\
   &#x20;

   <figure><img src="/files/mK332u1Jfs4iM8QeE8Kx" alt=""><figcaption><p>Right click Add State Category item</p></figcaption></figure>
4. Enter the name for the new category. By convention, categories should have the suffix "Category"
5. Click **OK**

### Including and Excluding Variables in Categories

By default a category categories do not set any variables. Any variable that should be set by the category must be explicitly added.

To exclude or exclude variables, click the **...** button in the State Data tab and use the **<<** and **>>** buttons to include and exclude variables.&#x20;

<figure><img src="/files/smjpbZ8hmVurMt2feEyy" alt=""><figcaption></figcaption></figure>

#### Excluding Variables Prevents Accidental Assignment

Excluding variables has two benefits:

1. Simplifies the grid so only relevant variables are displayed
2. Removes unnecessary assignment of variables when a state is set

### State Categories as StateData

StateData is the concept of treating states similar to CSV data. FlatRedBall supports treating States as CSV data by providing a CSV-like interface when selecting a category, as shown in the following image:

![](/files/7to4R3HzTm4zle9NpjRm)

For an in-depth discussion of State Data, including how to exclude variables from inclusion, see the [State Data blog post](https://flatredball.com/news/introducing-state-data/).


---

# 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.flatredball.com/flatredball/glue-reference/states/state-categories.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.
