StateTick Docs Home →
Tutorial

Global Variables in StateTick

Global variables are your program's shared memory — values that every part of your StateTick project can read and write. This tutorial covers what they are, the variable types available, and exactly how to create one.

What is a global variable?

A global variable is a named value that lives at the top level of your project and is visible everywhere — to every composite, FSM, condition and logic block. That is the difference from an interface variable, which belongs to a specific interface. Reach for a global when a value is genuinely shared across the whole machine: a run flag, a part counter, the current recipe, a temperature setpoint.

Global variables live in the Generic Composer → Global Variables page. Each one is a row with four columns: Name, Type, Size and Default Value.

The StateTick Composer with Generic Composer expanded in the sidebar and the Global Variables page selected, showing the Name, Type, Size and Default Value columns
Global Variables lives under Generic Composer, with a Name / Type / Size / Default Value grid.

The types of global variable

StateTick offers 16 variable types, in four families. Scalars hold a single value; arrays and maps hold collections; a record groups mixed types into one structured value.

FamilyTypesUse it for
ScalarBool, Int, Double, String, TimeA single value — a flag, a count, a measurement, a name, a duration.
ArrayArray:Bool, Array:Int, Array:Double, Array:String, Array:TimeA fixed-size, index-addressed list of one scalar type (set Size).
MapMap:Bool, Map:Int, Map:Double, Map:String, Map:TimeA key → value dictionary whose values are one scalar type.
RecordRecordA structure grouping several named fields of mixed types.

Note: arrays and maps use the Size column. For a map, adding the type is not enough — you must add the keys and their default values, or the build reports default value is required. A record's fields are edited in its own dialog.

How to create a global variable

Creating one takes four fields and a save:

  1. Open Generic Composer → Global Variables in the left sidebar.
  2. Click + Add. A new row appears, defaulting to a Bool named NewGlobal.
A newly added global variable row named NewGlobal11 with type Bool and default value false, plus the Save, Add and Remove buttons above the grid
Clicking Add creates an editable row — a Bool named NewGlobal, default false.
  1. Double-click the Name cell and type a clear name, e.g. MachineRunning.
  2. Pick a Type from the dropdown (one of the 16 above). For an array or map, set Size too.
  3. Set the Default Value. Select the row first, then edit the cell — e.g. false for a Bool, 0 for an Int, 25.5 for a Double.

Repeat for each variable you need. A handful of typical globals looks like this:

Four global variables in the grid: MachineRunning of type Bool default false, PartCount of type Int default 0, Temperature of type Double default 25.5, and RecipeName of type String default Idle
Four globals: a Bool flag, an Int counter, a Double measurement and a String name.

Save

Click Save to persist the Global Variables page (or Save All for the whole project). Your globals are now available to bind from any composite, condition or FSM in the project.

Try it in StateTick

Model your machine's shared state with global variables, then wire them into your control logic.

Get Started →