Recording and Mapping State Changes

The State Properties dialog below is for the State Parliament. The Constraints tab is open to show how the State is linked to the Class CXTrain. A State can be defined by a single constraint or by many; in the example below the State Parliament has two constraints.

State Constraints - Turquoise

The CXTrain Class has a member called Location of type int, and a member called Departing.Name of type CString.

The values of constraints can only be compared for elemental, enum and string types. What this constraint means is:

  • when an instance of the CXTrain Class exists and
  • its member variable Location has the value 0 and
  • the member variable Departing.Name has the value Parliament then
  • this State is evaluated to true.

Operators in Constraints

There are two types of operators you can use on constraints to define a State:

  • Logical operators AND and OR can be used to combine constraints
  • Equivalence operators {= and !=} can be used to define the conditions of a constraint.

All the constraints for a State are subject to an AND operation unless otherwise specified. You can use the OR operation on them instead, so you could rewrite the constraints in the above example as:

Location=0 OR

Location=1 AND


Below are some examples of using the equivalence operators:

Departing.Name!=Central AND



Quotes around strings are optional. The comparison for strings is always case-sensitive in determining the truth of a constraint.