Syntax
The SemEL syntax is a subset of the ECMAScript 2016 (ES7) and can be executed by SemBEE.
Variables Declaration
A variable is a storage location associated with an identifier that contains a value. The SemEL language lets you work with several types of variables, detailed in Data Types.
The variable name must begin with a letter (A-Z or a-z) followed by letters, digits (0-9)
or underscores (_). The scope of variables is global to the SemEL
script.
You can declare a variable using the var keyword and assign it a value
using the = operator.
var x; var y = 5; var s = "A string"; var array = []; var myAsset = new Asset();
Important:
let and const are not
supported. |
Reserved Keywords
The variable name cannot be one of the following reserved keywords:
var for if else true false of continue break new
Input and Output Variables
When a process invokes the SemEL script, it can transmit input parameters and retrieve output parameters. Those parameters are seen by the script as variables, and do not need to be declared.
Statements
A SemEL script is made up of statements, or instructions and each of which ends with a
semicolon (;).
Block Statements
Statements can be grouped in block statement using braces
{...}.
Conditional Statements
The if and else keywords are used to write conditional
statements.
if (condition) statement1 else statement2
Multiple if...else statements can be nested to create an else
if clause:
if (condition1) statement1 else if (condition2) statement2 else if (condition3) statement3 // … else statementN
You can also use an if statement to check if an object is defined or
not:
if (myObject) statement else //Log error
Loop Statements
- For Statements:
The
forstatement creates a loop with three optional expressions.for (expression1; expression2; expression3) { // code block to be executed }Expression1is executed once before the code block is executed.Expression2defines the condition for executing the code block.Expression3is executed each time after the code block has been executed. - For [… ] of Statements:
The
for...ofstatement executes a loop that operates on a sequence of values from an iterable object.for (var element of iterable) statement
For each iteration,
elementreceives a value from the sequence defined in theiterableobject andstatementis executed.You can use a block statement to execute several statements at once.
Note: Iterable objects can be arrays or multivalued properties of a structured object.The following example illustrates how to compute the sum of array values:
var sum = 0; var myArray = [1, 2, 3]; for (var nb of myArray) { sum += nb; } // Expected output: sum = 6 - Continue and Break Statements
The
continuestatement terminates the execution of the statements in the current iteration of the current loop, and continues the execution of the loop with the next iteration.The
breakstatement terminates the current loop statement and transfers program control to the statement following the terminated statement.
Comments
The code after the double slashes // is treated as a comment. Comments
are ignored and will not be executed:
var x = 5; // I will be executed // x = 6; I will NOT be executed
White Spaces
SemEL ignores multiple spaces, tabulations, and line breaks. You can use them to make your scripts more readable.