# Actions, Expressions, and Rules

In many places, Storyspace allows you to change what information it displays or what actions it performs on notes that you have created or moved. These symbolic actions and expressions can provide great flexibility and can save you lots of time. For example:

- A container that holds a “reading list” can know that notes added to the list are likely to be books or articles, and can automatically set the size, appearance, and prototype of new notes.
- A container that holds a set of “chapters” for your book can display the current total word-count for all notes inside it.
- An agent that contains “urgent tasks” can automatically change their color in order to draw your attention.

An expression is simply something that has a value. For example, the expression `0.05*$Price` might calculate the sales tax on an item based on its price.

An action describes a change made on one or more notes. For example, the action`$Color(California)="red"` sets the color of the note named “California” to “red”.

Quotes in Action code: action code will fail is you use typographic (curly) quotes. Action code must use plain (straight) quotes.

Actions may be performed at a variety of times.

- The OnVisit action is performed when the reader visits a note in Read mode.
- The BeforeVisit action is performed when Storyspace is examining whether a note can be visited.
- The OnReset action is performed at the start of a reading.
- The ResetAction action is performed when a note is added to a container, is discovered by an agent, or is placed atop an adornment, and affects the note being added.
- A Rule is performed at frequent intervals, and affects the note that possesses the rule.