You can use an Alf expression the guard for an Activity Edge (Object Flow or Control Flow) in an Activity. However, in this case, it is generally easier to create the Expression directly into the Specification window for the Activity Edge, and then subsequently edit it using the Alf editor.


To create an Alf guard Expression


  1. Open the Specification window for the Activity Edge on an Activity diagram.
  2. Click on the Guard property and then click on the button at the left of the field.

  3. 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.

    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 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.
  4. Click OK to close the Edit Guard window.
  5. Close the Specification window.


To edit an Alf guard Expression using the Alf editor


  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.


You also can 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


  1. Open the Specification window for the Activity Edge on an Activity Diagram.
  2. Click on the Guard property and then click on the button at the left of the field
  3. Edit the Alf expression as above.