8.3.1 Example: Creating an MLE Environment

This example demonstrates the creation of an MLE environment and demonstrates how a mapping is created between the identifier FACTORIAL_MOD and the JavaScript module FACTORIAL_MOD created in Example: Creating an MLE Module.

Create the MLE Environment

  1. In the MLE JS page, in the left pane, select Environments from the object type selector and then click Object submenu - Create Object.
    The Create MLE Environment panel appears.
  2. In the Name field, enter myfactorialenv.
  3. In the Available Modules field, select FACTORIAL_MOD. Click Add Selected Module to move the module to the Imported Modules field.

    Note:

    By default, the Import Name matches the Module name. You can edit the import name by clicking in the associated column cell and typing in the new name.
    Create MLE Environment Panel
  4. Click Create.
    The Output pane displays the underlying source code along with a CREATED notification.
  5. Click Close.
    The new environment is now available in the left Navigator pane. (If you do not see it, click Refresh in the left pane.)

Create the MLE module that Imports FACTORIAL_MOD

  1. In the MLE JS page, in the left pane, select Modules from the object type selector and then click Object submenu - Create Object.
  2. In the right pane, select the Editor tab, and enter the following JavaScript function:
    import * as h from "FACTORIAL_MOD";
    
    export function factorial_3(){
        console.log('The factorial of 3 is:' + h.factorial(3));
    }
    
  3. In the Name field, enter mod_imp_fact.
  4. In the Environment field, select MYFACTORIALENV.
    Module Code in Editor Tab
  5. Click Save Module.
    A notification that the module is saved in the database is displayed.