An Alf expression can be used as the guard for a Transition in a State Machine. However, in this case, it is generally easier to enter the Expression directly into the Specification window for the Transition, rather than to use the Alf editor window. It can then subsequently be edited using the Alf editor.
To create an Alf guard Expression
- Open the Specification window for the Transition (from the Model Browser or as represented on a State Machine diagram).
In the Transition section, click on the Guard property and then click on the
button at the right of the field.
In the Edit Guard window, select Alf for Language (you may need to scroll up in the menu) and enter the Alf code for the expression into the Body field.

- Click OK to close the Edit Guard window.
- Close the Specification window.
To edit an Alf guard Expression in the Alf editor
- 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.

You can also edit the Alf code in the Edit Guard window 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.
To edit an Alf guard Expression in the Edit Guard window
- Open the Specification window for the Transition (from the Model Browser or as represented on a State Machine diagram).
In the Transition section, click on the Guard property and then click on the
button at the right of the field.
Edit the Alf expression as above.