Author: Daniel Bergqvist
Keywords: jmri LogixNG reference basic actions expressions

# LogixNG Reference - Chapter 4

## Actions and Expressions

LogixNG has four basic building blocks: Actions, Expressions, Male sockets and Female sockets.

Actions do something, for example throw a turnout or sets a signal mast. Expressions ask something, for example if a sensor is active or if a signal head has a particular appearance. The actions and expressions form a tree and complex logic can be built with them.

Each action/expression is embedded in one or several male sockets. Male sockets allow actions/expressions to be connected to a female socket of the correct type.

A ConditionalNG has a female socket that is the root of the ConditionalNG tree. And some actions/expressions have one or several female sockets as children. There are several different types of female sockets and the female socket type decides which types of actions or expressions can be connected.

### Categories

Since there is a large number of actions and expressions, they are assigned a category. The main categories are Item and Common.

- Item - Actions and expressions related to items on the layout, for example turnouts and signal masts
- Common - The most important actions and expressions that are not in the Item category
- Display - Actions and expressions related to Panels
- LocoNet - Actions and expressions related to LocoNet
- Other - Other actions and expressions

### Action and Expression types

Each action and expression is built for a specific socket type.

Symbol | Type | Description | Categories
--- | --- | --- | ---
! | Digital action | Execute, no parameter | Item, Common, Other, Display, LocoNet
!b | Digital boolean action | Execute using a boolean parameter | Common
!~ | Analog action | Execute using a double parameter | Item, Common
!s | String action | Execute using a string parameter | Item, Common
? | Digital expression | Return boolean | Item, Common, Other, LocoNet
?~ | Analog expression | Return a double | Item, Common
?s | String expression | Return a string | Item, Common
?* | Generic expression | Return an Object | (Digital, Analog, and String merged)

Notes:

- string is text, such as "hello world"
- boolean is true or false
- double is a number, such as 42 or 3.14
- Generic expression can handle any expression type

### Adding an action or expression

When Add is selected from the context menu for an empty socket, the selection dialog is displayed.

The Category selection automatically adjusts the Type list based on the socket type. For example, Digital Action socket using the Item category is quite long while Analog Action socket using the Common category is short. The Type list always displays the valid selections for the socket type and category.

There are 20 combinations of socket types and categories. These are described in Chapter 5 - Actions and Chapter 6 - Expressions.

Chapter 5 - Action Descriptions

Return to the Reference TOC