You can use the Alf editor to create an Alf Expression for the guard of a Transition in a State Machine or to edit an existing guard Expression.
To create an Alf guard Expression
- Select the Transition (in the Model Browser or as represented on a State Machine diagram) and open the Alf editor window (select Windows > Alf), if it isn't already open.
- In the Alf editor window, press Create. A menu will pop up with available options for creating a Transition effect Behavior or guard Expression.

- Select Guard Expression.
Enter the Alf code for the Expression and press Save to compile and save it.
To edit an Alf guard Expression
- Open the Alf editor window (select Window > Alf), if it is not already open.
On the State Machine diagram, click on the text of the Transition trigger with the guard to be edited.
- Enter the Alf code for the guard Expression and press Save to compile and save it.

The Alf code for a guard Expression can also be entered or edited directly in the Guard property in the Specification window of the Transition. If you open the Edit Guard window, then the Alf code can be edited just as in the Alf editor window. However, instead of Save and Revert buttons, this window has OK and Cancel buttons, either of which will close it. If you press OK, then the Alf text is saved, and, if it has no errors, compiled. If you press Cancel, the Alf text is not saved.

Editing code for a Transition guard Expression in the Edit Guard Window