Defining a Script

EMGscript files have a .emjs extension.  To create a new script, right-click in the Script Manager and select New Script....  This will create a new script file with a default script template.  The default template is shown below.

/**
* Script Documentation
* @name Example Script
* @version 0.0.0.0
* @author Your Name
* @signed 0
* @namespace MYS
*/

 

MYS = {

Calculate : function()
   {
    // enter the logic for your script here
    // assign outputs to MYS.Output.ExampleOutputA
   },

Input : 5,

OutputTemplate:
           {
              ExampleOutputA: {seq: 1, name: "First Example Output"},
              ExampleOutputB: {seq: 2, name: "Second Example Output"},
           },

Validate : function()
           {
              if (false /* replace with a test for invalid parameters */)
     return "Error message text.";
           },

ParameterTemplate:
           {
     ExampleInputA: {seq: 1, name: "Series Input", type: "series"},
     ExampleInputB: {seq: 2, name: "Numeric Input", type:"number", initial: 5, min: 3, max: 10},
     ExampleInputC: {seq: 3, name: "Boolean Input", type: "bool", initial : "false"},
     ExampleInputD: {seq: 4, name: "Enumeration Input", type: {"enum" :[ "Option 1", "Option 2", "Option 3"]}, initial: "Option 2"},
   },
}

More:

Script Header

Script Namespace

Script Primary Input

Script Parameter Template

Script Parameters

Script Output Template

Script Validation

Script Calculation