You can use the Alf editor to create an Alf Expression for the guard for an Activity Edge (Object Flow or Control Flow) in an Activity or to edit an existing guard Expression.


To create an Alf guard Expression


  1. Select the Activity Edge and open the Alf editor window (select Windows > Alf), if it isn't already open.
  2. In the Alf editor window, press Create.
  3. Enter the Alf code for the Expression and press Save to compile and save it.

    Note that the text entered must be for an expression, not a statement. Therefore, it must not have a semicolon at the end.


    The Expression can access attribute values of the context Classifier of the Activity containing its Activity Edge (using Alf this expressions) or the decision input value for the Decision Node (see Accessing data in Activity Edge guards).



To edit an Alf guard Expression


  1. Select the Activity Edge and open the Alf editor window (select Windows > Alf), if it isn't already open.
  2. Edit the guard Expression and click Save to save and compile 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 Activity Edge. 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 an Activity Edge guard Expression in the Edit Guard window

To be recognized as Alf code, the Body of an Opaque Expression must have the Language Alf. If your project was created using the Alf project template, then Alf will be the default language. Otherwise, select Alf from the Language menu (you may have to scroll upwards in the menu to find the selection for Alf).


To make Alf the default language for Opaque Expressions


  1. Select Options > Environment.
  2. From the General options, select Editing.
  3. For the Opaque Expression Default Language option, type Alf (with exactly that spelling and capitalization). Click OK