Adding Functions

You can instantiate functions in the Block Editor.

This task shows you how to:


Before you begin: The Block Editor workbench should be opened.

Add Predefined Functions

The predefined functions are available in the specification tree. They can be reused in different blocks.

  1. If a function is not available in the current logic workspace, you can create one (see Defining Functions) or use a function available in the pervasive library.

    1. Select object > Show Content in the contextual menu of @@Pervasives in the specification tree.

    2. Expand @@Pervasives to access its content. All the predefined functions and types are available in this library.

    3. Expand the module Bool to access the Boolean functions.



  2. Click the not function and select Add function in the Predefined Blocks toolbar.

  3. Click the place in the blank sheet where you want to position the function.



  4. Double-click the block to open its properties.

    The Function Block Properties dialog box is displayed.

    Name/Comment


    • Function: This field contains the name of the function.

    • Instance Name: You can change the name of the instance by filling this field.

    • Visible: You can choose to display the function name or its instance name in the viewer.

    • Comment: The comment of the block is displayed in a tool tip when you move the mouse over the instance.

    • Ports Name Visible: You can display the name of the ports in the viewer by checking this box.

    Activation/Reset Ports


    • Use Activation Port: When the check box is selected, a boolean input is added at the top left side of the block. The function is executed only if this port is true.

    Output Ports Default Value


    • Visible: You can display the default value of the output ports in the viewer by checking this box.

    • Default: You can fill a default value. Default values are emitted as long as the block has never been activated (see Activation above).

Add Local Functions

Local functions are directly created in the Block Editor. Their usage remains local to the block.

  1. Select Add User Function in the Predefined Blocks toolbar.

  2. Click the place in the blank sheet where you want to position the function. The User Function Block Properties dialog box is displayed.



  3. Click Parameters in the left-side tree.

  4. Set the input parameters:



    1. Click twice on Add Param .
    2. Set the inputs names A and B.
    3. Select the Type using the combo.

  5. Check Named Interface to display the name of the input parameters in the 2D viewer.

    If Named Interface is selected, the root parameter of the function input is a structure. Otherwise it is a tuple.

  6. Click Result in the left-side tree.

  7. Select Tree Mode. This mode is more convenient if the result is a structured data.

  8. Enter the function result.

    1. Click twice on Add Param .

    2. Set the structure element names to Perimeter and Surface.

    3. Enter the result expression.



    4. You can switch to Text Mode to see the result in that mode.



  9. Click the Properties tab. You can change the default instance name of the block. You can use the Visible check boxes to define whether the value of the function or the instance name will be displayed in the Block editor.



    When Automatic is checked, the name of the instance is the expression of the function.

  10. Click OK. The function block is displayed in the blank page. The instance is added to the tree.