User-Defined Function

A user-defined function is a customised function created by the users and can be imported into another Mobius file. User-defined functions can be designed to perform any operations, such as creating new entities, modifying existing entities, and returning values.

User-Defined Function that Creates New Entities
Figure: User-Defined Function that Creates New Entities
User-Defined Function that Modifies Existing Entities
Figure: User-Defined Function that Modifies Existing Entities
User-Defined Function that Returns Values
Figure: User-Defined Function that Returns Values


Creating a User-Defined Function

Have a general idea of the desired returns of the user-defined function and decide on the parameters before writing the procedures.


Start Node
  1. Title of the flowchart will become the name of the imported function.
  2. Names of the parameters will appear as the names of argument box in the Procedure Line.
  3. Description of the flowchart and description of parameters will be displayed in the Tooltip and Help Viewer of the function.
Start Node of the flowchart to be exported
Figure: Start Node of the flowchart to be exported
Tooltip, Procedure Line and Help Viewer of the imported user-defined function
Figure: Tooltip, Procedure Line and Help Viewer of the imported user-defined function


Working Node

Write procedures with the parameters like how it is normally done. The operations performed on the parameters in this flowchart will be likewise performed on the inputs in the argument boxes of the exported user-defined function.

Working node of the flowchart to be exported
Figure: Working node of the flowchart to be exported
Returns of the imported user-defined function
Figure: Returns of the imported user-defined function


End Node

The Return Section in the End Node that determines what information can be returned and worked with if the flowchart is imported as a user-defined function. It is not always necessary to fill the Return Section because one may or may not need to work with the returns of a user-defined function.


Scenario 1. User-Defined Functions that Return Entities

If a user-defined function is created with the Return Section left unfilled, the user-defined function will not have a variable declaration box when used.

The user-defined function will thus work like a modify functions in Mobius where the return of the code can be observed in the 3D Viewer but users cannot print any returns in the Console. Users can only work with the returns of the function after having obtained them using the query.Get function.

Unfilled Return Section of the flowchart to be exported
Figure: Unfilled Return Section of the flowchart to be exported
Imported user-defined function without a variable declaration box
Figure: Imported user-defined function without a variable declaration box

If a user-defined function is created with the Return Section filled, the user-defined function will have a variable input box when used.

The returns of the user-defined function can be defined and then worked with right away, without having to use the query.Get function.

Filled Return Section of the flowchart to be exported
Figure: Filled Return Section of the flowchart to be exported
Imported user-defined function with a variable declaration box
Figure: Imported user-defined function with a variable declaration box


Scenario 2. User-Defined Functions that Do Not Return Entities

In cases where the user-defined functions return information such as numerical values or strings instead of entities, using the Return Section in creating the functions is necessary.

This is because such returns can only be viewed by printing them on the Console. Having the variable declaration box is essential for the users to access the return values, as the query.Get function cannot return non-entities.

Filled Return Section of the flowchart to be exported
Figure: Filled Return Section of the flowchart to be exported
User-defined function that returns values
Figure: User-defined function that returns values


Exporting a User Defined Function

Save the flowchart as a MOB file through the File Menu.


Importing a User Defined Function

  1. Go to Procedure Menu: Functions > User > Import.
  2. Select the flowchart (MOB file) to import from the file browser.
  3. Click on the function to add it into the Procedure Space.
  4. Users may also delete or download the function by clicking the cross or download icon.
Importing a User Defined Function
Figure: Importing a User Defined Function

results matching ""

    No results matching ""