Esta página no está disponible actualmente en Español. Si lo necesita, póngase en contacto con el servicio de asistencia de Icon (correo electrónico)

Creating a Function Library

The following how-to guide will walk through the steps required to create a function library using the Rules Designer in the Simple Language. The example shown is fairly trivial, however far more complicated functions can be defined in much the same way.

Prerequisites

  • MPS (version 2022.3.1)

  • A model using the com.iconsolutions.simple.devkit, or a devkit that uses it (e.g. v2Flo.devkit)

Steps

1. Create Function Library Node

To add a function into a model, go to the Logical View window on the left hand side of MPS and right-click on the model where the function library is required. Then navigate to New > com.iconsolutions.simple > Function Library.

It should look like the image below:

create a function library step 1

2. Name Function Library

An unimplemented function library should have been created now. All function libraries need a name so that they can be referenced elsewhere. Place the cursor on the red cell that says <no name> to the right of Name: and enter the function’s name.

In the example below, the name is set to ExampleFunctionLibrary:

create a function library step 2

3. Define Functions

Any number of functions can be defined within a library. To add a new function select the box, or the name of an existing function and press enter.

create a function library step 3

The functions defined within this table are very similar to private functions.

The type column is for the type of the function’s outcome. This can be inferred by leaving it blank, although it is recommended to explicitly give the type.

The args column contains the function inputs. To add more arguments press enter while within the cell. Arguments each have a name and a type. First type the name of the input, then press : followed by enter. Now to choose a type press Ctrl+Space to see the list of options.

The body column contains an expression representing the function.

create a function library step 4