Skip to content

Script Functions List

Script Functions

Canvas Scripts

All functions must be used with parentheses

Note: USBs must be formatted in exFAT or FAT32 to be used with the eXT, nXT, and eXT2 series.

Note: when using Storage.Local as a storage location, the Xpanel refers to the path $DATA_PARTITION/home/user while the simulator refers to the path C:\Users\<user>.

Alarm

Function Parameters
and
Return Value
Description
and
Example
alarm.createAllCsv(Storage type) Storage type:
1: Storage.Local
2: Storage.Usb
3: Storage.SdCard
4: Storage.Ftp

Returns:
No return value
Saves all the messages at the assigned Storage type as a CSV.
alarm.createAllCsv(Storage.Usb);
alarm.createAllCsv(1);
alarm.createCsv(String label, Storage type) String label:
Label used within the alarm settings.

Storage type:
1: Storage.Local
2: Storage.Usb
3: Storage.SdCard
4: Storage.Ftp

Returns:
No return value
Saves all the alarm messages associated with the String label at the assigned Storage type as a CSV.
String label refers to one of the labels within the Alarm Settings. Users can create their own labels or use a preset label.
alarm.createCsv("A", Storage.Usb);
alarm.createCsv("A", 1);

Data Log

Function Parameters
and
Return Value
Description
and
Example
datalog.addRow(String modelName) String modelName:
Name of the data log model to target

Returns:
No return value
Adds a single row to the specified data log model.
datalog.addRow("LoggingModel");
datalog.createCsv(String modelName, Storage type) String modelName:
Name of the data log model to target

Storage type:
1: Storage.Local
2: Storage.Usb
3: Storage.SdCard
4: Storage.Ftp

Returns:
No return value
Creates a CSV file of the data log model specified at the designated Storage type.
datalog.createCsv("LoggingModel", Storage.Local);
datalog.createCsv("LoggingModel", 4);
datalog.
createCsvForRange(String modelName, Date start, Date end, Storage type)
String modelName:
Name of the data log model to target

Date start:
Starting date

Date end:
Ending date

Storage type:
1: Storage.Local
2: Storage.Usb
3: Storage.SdCard
4: Storage.Ftp

Returns:
No return value
Creates a CSV file of the data log model specified at the designated Storage type with a set time boundary.
          datalog.createCsvForRange(
            "LoggingModel", 1, 31, Storage.Ftp);
        
          datalog.createCsvForRange(
            "LoggingModel", 1, 31, 1);
        
datalog.start(String modelName) String modelName:
Name of the data log model to target

Returns:
No return value
Begins logging for the data log model specified.
datalog.start("LoggingModel");
datalog.stop(String modelName) String modelName:
Name of the data log model to target

Returns:
No return value
Ends logging for the data log model specified.
datalog.stop("LoggingModel");

Driver

Function Parameters
and
Return Value
Description
and
Example
driver.enable(String deviceName) String deviceName:
Name of the driver to target

Returns:
No return value
Enables the specified device.
driver.enable("PLC");
driver.disable(String deviceName) String deviceName:
Name of the driver to target

Returns:
No return value
Disables the specified device.
driver.disable("PLC");

Keyboard

Function Parameters
and
Return Value
Description
and
Example
keyboard.
launchKeyboard(String tagName)

keyboard.
launchKeyboard(String tagName, Object properties)
String tagName:
Name of the tag to set

Object properties:
Optional parameter
List of keyboard style properties
  • header: Text at the top of the keyboard.
  • subheader: Text below the header.
  • x: Sets the X position for the keyboard.
  • y: Sets the Y position for the keyboard.


Returns:
No return value
Launches a popup keyboard for user input to set the value of a tag.
keyboard.launchKeyboard("pass");
          keyboard.launchKeyboard("pass", {header: "Password", subheader: "Enter your password", x: 50, y: 50});
        
keyboard.
launchKeypad(String tagName)

keyboard.
launchKeypad(String tagName, Object properties)
String tagName:
Name of the tag to set

Object properties:
Optional parameter
List of keypad style properties
  • header: Text at the top of the keypad.
  • subheader: Text below the header.
  • x: Sets the X position for the keypad.
  • y: Sets the Y position for the keypad.
  • format: Specifies Hexadecimal or decimal input.
  • rawMin: Sets the minimum value accepted.
  • rawMax: Sets the maximum value accepted.
  • scaledMin: Sets the minimum scaled value.
  • scaledMax: Sets the maximum scaled value.


Returns:
No return value
Launches a numeric popup keypad for user input to set the value of a tag.
keyboard.launchKeypad("Number");
          keyboard.launchKeypad("Number", {header: "Header", subheader: "Subheader", x: 50, y: 50, format: "HH", rawMin: 5, rawMax: 20});
        
keyboard.
sendKeyEvent(KeyCode keyCode)
KeyCode keyCode:
Hexadecimal or decimal value of the key

Returns:
No return value
Simulates a keystroke for a keycode.
keyboard.sendKeyEvent(0x20);

Notification

Function Parameters
and
Return Value
Description
and
Example
notification.send(String msg)

notification.send(String msg, int dismissInterval)
String msg:
Message to display

int dismissInterval:
Optional parameter
Amount of time, in milliseconds (ms), before the notification disappears

Returns:
Unsigned long value
Sends a popup notification to the screen displaying the specified message and returns an unsigned long unique ID.
If dismissInterval is less than 0, the message will display until it is manually dismissed.
tag.write("ID", notification.send("Hello World"));
// Save the unique ID of the notification
tag.write("ID", notification.send("Hello World", 3000));
// Save the unique ID of the notification

Page

Function Parameters
and
Return Value
Description
and
Example
page.close(String name) String name:
Name of the page

Returns:
No return value
Closes the base page with the specified name.
page.close("Home");
page.closeIndex(int index) int index:
Number of the page

Returns:
No return value
Closes the base page with the specified index number.
page.closeIndex(1);
page.closePopupIndex(int index) int index:
Number of the popup page

Returns:
No return value
Closes the popup page with the specified index number.
page.closePopupIndex(3);
page.currentIndex() Returns:
int value of the index of the currently opened page
Returns the index of the currently opened page.
tag.write("Page Num", page.currentIndex()); 
// Set the "Page Num" tag to the index of the currently opened page
page.currentName() Returns:
String value of the name of the currently opened page
Returns the name of the currently opened page.
tag.write("Open Page", page.currentName());
// Set the "Open Page" tag to the name of the currently opened page
page.isOpen(String name) String name:
Name of the page

Returns:
Boolean value
Returns a boolean value, true (1) or false (0), if the base page with the specified name is open.
if(page.isOpen("Home")) {
tag.write("Pages/Base/Home", 1); 
// If the home page is open, set the tag to true
}
page.isOpenIndex(int index) int index:
Number of the page

Returns:
Boolean value
Returns a boolean value, true (1) or false (0), if the base page with the specified index is open.
if(page.isOpenIndex(0)) {
tag.write("Pages/Base/Home", 1); 
// If the home page is open, set the tag to true
}
page.isOpenPopupIndex(int index) int index:
Number of the page

Returns:
Boolean value
Returns a boolean value, true (1) or false (0), if the popup page with the specified name is open.
if(page.isOpenPopupIndex(3)) {
tag.write("Pages/Popup/Help", 1); 
// If the help popup page is open, set the tag to true
}
page.open(String name) String name:
Name of the page

Returns:
No return value
Opens the base page with the specified name.
page.open("Home");
page.openIndex(int index) int index:
Number of the page

Returns:
No return value
Opens the base page with the specified index number.
page.openIndex(1);
page.openPopupIndex(int index) int index:
Number of the popup page

Returns:
No return value
Opens the popup page with the specified index number.
page.openPopupIndex(3);
page.openPrevious() Returns:
No return value
Opens the previous base page.
page.openPrevious();

Recipe

Function Parameters
and
Return Value
Description
and
Example
recipe.
createRecord(String recipe, int id, String name, List<Value> values)
String recipe:
Recipe database to target

int id:
ID of the record

String name:
Name of the record

List<Value> values:
List of parameter values to store in the record

Returns:
No return value
Adds a new record with the given parameters to the recipe database.
recipe.createRecord
("RecipeName", tag.read("MaxRecordId") + 1, "Orange", ["#FFA500"]);
recipe.
deleteRecord(String recipe, int id)
String recipe:
Recipe database to target

int id:
ID of the record

Returns:
No return value
Deletes an existing record from the recipe database.
recipe.deleteRecord
("RecipeName", tag.read("Switch"));
recipe.
exportCsv(String recipe, Storage type, String path)
String recipe:
Recipe database to target

Storage type:
1: Storage.Local
2: Storage.Usb
3: Storage.SdCard
4: Storage.Ftp

String path:
Refers to where to find the CSV file, relative to the storage location

Returns:
No return value
Saves the recipe data in a CSV file at the specified path.
recipe.exportCsv
("RecipeName", Storage.SdCard, "RecipeScript.csv");
recipe.exportCsv
("RecipeName", 1, "RecipeScript.csv");
recipe.
getAllParameters(String recipe)
String recipe:
Recipe database to target

Returns:
Array of the current tag values
Returns an array of the current parameter values from the device (the current tag values).
          var vals = 
recipe.getAllParameters("Mix"); 
// Get all current parameter values
tag.write("Mix/Display/1", vals[0]); 
// Write the first element of the array to tag 1
tag.write("Mix/Display/2", vals[1]); 
// Write the second element of the array to tag 2
tag.write("Mix/Display/3", vals[2]); 
// Write the third element of the array to tag 3
        
recipe.
getParameter(String recipe, int id, int index)
String recipe:
Recipe database to target

int id:
ID of the record

int index:
Parameter index within the record

Returns:
Value of the record's parameter by the given parameter index
Returns the value of the record's parameter by the specified parameter index.
This is similar to the recipe.getParameterByName() script.
          var para = recipe.getParameter
("Mixtures", 1, 2); 
// Get parameter value
tag.write("Mix/Display/Parameter", para); 
// Write the parameter value to a displayable tag
        
recipe.
getParameter
ByName(String recipe, int id, String name)
String recipe:
Recipe database to target

int id:
ID of the record

String name:
Name of the record parameter

Returns:
Value of the record's parameter by the given parameter name
Returns the value of the record's parameter by the specified parameter name.
This is similar to the recipe.getParameter() script.
          var para = 
recipe.getParameterByName
("Mixtures", 0, "Ingredient 2"); 
// Get parameter value
tag.write("Mix/Display/Parameter", para); 
// Write the parameter value to a displayable tag
        
recipe.
getRecordName(String recipe, int id)
String recipe:
Recipe database to target

int id:
ID of the record

Returns:
String name of the record
Returns the name of the record in specified recipe database.
          var name = 
recipe.getRecordName
("Mixtures", 2); 
// Get record name
tag.write("Mix/Display/Name", name); 
// Write the record name to a displayable tag
        
recipe.
getRecordValues(String recipe, int id)
String recipe:
Recipe database to target

int id:
ID of the record

Returns:
Array of parameter values
Returns an array of the values of the specified record.
          var record_values = 
recipe.getRecordValues("Mixtures", 1); 
// Get record values
tag.write("Mix/Values/Value 1", record_values[0]); 
// Write the record name to a displayable tag
tag.write("Mix/Values/Value 2", record_values[1]); 
// Write the record name to a displayable tag
tag.write("Mix/Values/Value 3", record_values[2]); 
// Write the record name to a displayable tag
        
recipe.
importCsv(String recipe, Storage type, String path)
String recipe:
Recipe database to target

Storage type:
1: Storage.Local
2: Storage.Usb
3: Storage.SdCard
4: Storage.Ftp

String path:
Refers to where to find the CSV file, relative to the storage location

Returns:
No return value
Replaces recipe data with the data found in a CSV at the path.
recipe.importCsv
("RecipeName", Storage.Usb, "RecipeScript.csv");
recipe.importCsv
("RecipeName", 1, "RecipeScript.csv");
recipe.openConfig() Returns:
No return value
Opens the recipe config window.
recipe.openConfig();
recipe.receiveRecord(String recipe, int id) String recipe:
Recipe database to target

int id:
ID of the record

Returns:
No return value
Gets the recipe values from a remote device and saves them in the recipe database.
recipe.receiveRecord("Mixtures", 0);
// Get record 0 from the "Mixtures" recipe
recipe.sendRecord(String recipe, int id) String recipe:
Recipe database to target

int id:
ID of the record

Returns:
No return value
Sends the values of the specified record in the recipe database to the remote device.
recipe.sendRecord("Mixtures", 3);
// Send record 3 from the "Mixtures" recipe
recipe.
setParameter(String recipe, int id, int index, Value value)
String recipe:
Recipe database to target

int id:
ID of the record

int index:
Parameter index within the record

Value value:
Value to be input into the parameter

Returns:
No return value
Sets the value of the record's parameter by the specified parameter index.
This is similar to the recipe.setParameterByName() script.
recipe.setParameter
("Mixtures", tag.read("Counter"), 0, "#FFA500");
// Change the color of the mixture for the record ID "Counter"
recipe.
setParameterByName(String recipe, int id, String name, Value value)
String recipe:
Recipe database to target

int id:
ID of the record

String name:
Parameter name within the record

Value value:
Value to be input into the parameter

Returns:
No return value
Returns the value of the record's parameter by the specified parameter name.
This is similar to the recipe.setParameter() script.
recipe.setParameterByName
("Mixtures", tag.read("Counter"), "Color", "#FFA500");
// Change the color of the mixture for the record ID "Counter"
recipe.
setRecord(String recipe, int id, List<Value> values)
String recipe:
Recipe database to target

int id:
ID of the record

List<Value> values:
List of parameter values to store in the record

Returns:
No return value
Updates the values of a record.
recipe.setRecord("Mixtures", tag.read("Counter"), ["#FFA500"]);
recipe.
setRecordId(String recipe, int oldId, int newId)
String recipe:
Recipe database to target

int oldId:
ID of the record to update

int newId:
ID to update the record to

Returns:
No return value
Updates the record ID for a record in the specified recipe database.
recipe.setRecordId("RecipeName", tag.read("Switch"), tag.read("Switch") + 1); // Change the value of record "Switch" to "Switch + 1" (int value)
recipe.
setRecordName(String recipe, int id, String name)
String recipe:
Recipe database to target

int id:
ID of the record

String name:
Name to change the record to

Returns:
No return value
Updates the name of a record from the specified recipe database.
recipe.setRecordId("RecipeName", tag.read("Switch"), "Mixtures");

Schedule

Function Parameters
and
Return Value
Description
and
Example
schedule.isEnabled(String title) String title:
Name of the schedule

Returns:
Boolean value
Returns a boolean value, true (1) or false (0), if the schedule is enabled.
if(schedule.isEnabled("Check")) 
        { tag.write("Lights/Display", "#00FF00"); // Change the light to green if enabled
        }
schedule.setEnabled(String title, boolean enable) String title:
Name of the schedule

boolean enable:
0: false
1: true

Returns:
No return value
Sets the specified schedule to enabled if the value is 1 or disabled if the value is 0.
schedule.setEnabled("Check", 1); // Set the "Check" schedule to be true

System

Function Parameters
and
Return Value
Description
and
Example
system.audio.playFile(Storage type, String relativePath, boolean async) Storage type:
1: Storage.Local
2: Storage.Usb
3: Storage.SdCard
4: Storage.Ftp
5: Storage.Project

String relativePath:
Path of the file

boolean async:
Optional parameter
Run asynchronously
0: false
1: true

Returns:
No return value
Plays an audio file.
If the boolean async parameter is absent, the default value is true.
Previously sold CM-eXT07 and CM-nXT07 devices produced before November of 2024 do not support this feature.
system.audio.playFile(
          Storage.Project, "Folder/buzz.mp4", 0);
system.audio.playFile(
          5, "Folder/buzz.mp4");
system.audio.stopFile(Storage type, String relativePath) Storage type:
1: Storage.Local
2: Storage.Usb
3: Storage.SdCard
4: Storage.Ftp
5: Storage.Project

String relativePath:
Path of the file

Returns:
No return value
Stops all audio files.
Previously sold CM-eXT07 and CM-nXT07 devices produced before November of 2024 do not support this feature.
system.audio.stopFile(
          Storage.Project, "Folder/buzz.mp4");
system.audio.stopFile(
          5, "Folder/buzz.mp4");
system.audit.log(String description) String description:
Text to be added to the audit log

Returns:
No return value
Logs the entered description in the audit log.
system.audit.log("Button pressed");
system.currentUsername() Returns:
String value of the currently logged-in user's name
Returns the current username of the current logged-in user.
If no user is logged in, an empty String is returned.
var user = system.currentUsername(); // Get the current username
        tag.write("Username", user); // Write the username
system.
display.brightness()
Returns:
double value
Returns a double value between 0 and 1 representing the brightness level of the Xpanel.
This script will not work in the simulator.
if(system.display.brightness() < 1) {
  // Do something
}
system.
display.dimDelay()
Returns:
int value
Returns an int value representing the Xpanel dim delay time, in minutes.
This script will not work in the simulator.
if(system.display.dimDelay() > 5) {
  // Do something
}
system.
display.enableBacklight(boolean enable)
boolean enable:
Enable the Xpanel backlight
0: false
1: true

Returns:
No return value
Turns the backlight of the Xpanel on (1) or off (0).
This script will not work in the simulator.
Warning: Do not use this script with the auto-dimming or auto-sleep features. It may cause unintended behavior.
system.display.
        enableBacklight(0);
system.
display.isDimmerEnabled()
Returns:
Boolean value
Returns a boolean value, true (1) or false (0), if the dimmer setting is enabled.
This script will not work in the simulator.
if(!system.display.
        isDimmerEnabled()) {
  // Do something
}
system.
display.setBrightness(float brightness)
float brightness:
Brightness level of the Xpanel

Returns:
No return value
Sets the specified brightness of the Xpanel.
Note: the float brightness parameter must be between 0 and 1, and 0 brightness does not completely turn off the backlight.
This script will not work in the simulator.
system.display.
        setBrightness(0.74);
system.
display.setDimDelay(int minutes)
int minutes:
Time until the Xpanel dims

Returns:
No return value
Sets the time, in minutes, before the Xpanel dims.
Note: if int minutes is negative, the delay is 0.
This script will not work in the simulator.
system.display.
        setDimDelay(3);
system.
display.setDimEnabled(boolean enabled)
boolean enable:
0: false
1: true

Returns:
No return value
Turns the Xpanel dimmer on (1) or off (0).
This script will not work in the simulator.
system.display.
        setDimEnabled(0);
system.email.send(Object properties) Object properties:
Contents of the email
  • to: Email address of recipient
  • cc: Additional email addresses to carbon copy
  • subject: Email subject header
  • body: Email information and content


Returns:
No return value
Sends an email using the SMTP settings.
var properties = { 
          to: "test@gmail.com", 
          cc: "test2@gmail.com", 
          subject: "Script Email Send", 
          body: "This email is an example of how the system.email.send function works." 
          };
          system.email.send(properties);
system.execute(String program, Array arguments) String program:
The program to run

Array arguments:
Array of arguments for the program

Returns:
No return value
Create a non-blocking asynchronous call for the subprocess of String program with the Array arguments.
system.execute("bash", ["-c", "echo hello > out.txt"]); 
// Write "hello" to out.txt
system.execute("mkdir", ["newDirectory"]);
// Make a new directory called "newDirectory"
system.exit() Returns:
No return value
Closes the current project and runtime application.
system.exit();
system.file.exists(Storage type, String path) Storage type:
1: Storage.Local
2: Storage.Usb
3: Storage.SdCard
4: Storage.Ftp

String path:
File path

Returns:
Boolean value
Returns a boolean value, true (1) or false (0), if the file exists.
if(system.file.exists
        (Storage.Local, "Recipes.csv")) {
          recipe.exportCsv("Mixtures", Storage.Usb, "Recipes.csv"); // Export the file if it exists
        }
if(system.file.exists
        (1, "Recipes.csv")) {
          recipe.exportCsv("Mixtures", 2, "Recipes.csv"); // Export the file if it exists
        }
system.file.isDirectory(Storage type, String path) Storage type:
1: Storage.Local
2: Storage.Usb
3: Storage.SdCard
4: Storage.Ftp

String path:
Directory path

Returns:
Boolean value
Returns a boolean value, true (1) or false (0), if the file path is a directory.
if(system.file.isDirectory
        (Storage.Local, "Recipes") &&
        system.file.exists
        (Storage.Local, "Recipes.csv")) {
          recipe.exportCsv("Mixtures", Storage.Usb, "Recipes.csv"); // Export the file if it exists in a valid directory
        }
system.file.openDialog(Storage type, String path) Storage type:
1: Storage.Local
2: Storage.Usb
3: Storage.SdCard
4: Storage.Ftp

String path:
Directory path

Returns:
String value of the file selected
Returns a String value of the file selected from the storage location.
var file = system.file.openDialog(1, "Documents");
tag.write("File", file); // Display the name of the file selected
system.file.openPdf(Storage type, String path) Storage type:
1: Storage.Local
2: Storage.Usb
3: Storage.SdCard
4: Storage.Ftp
5: Storage.Project

String path:
Path to the PDF file

Returns:
No return value
Opens a PDF with a separate PDF viewer.
This script will not work in the simulator.
system.file.openPdf
        (Storage.Project, "Folder/help.pdf");
system.file.openPdf(5, "Folder/help.pdf");
system.file.saveDialog(Storage type, String path) Storage type:
1: Storage.Local
2: Storage.Usb
3: Storage.SdCard
4: Storage.Ftp

String path:
Path to the file

Returns:
String value of the file saved
Opens a dialog window to save a file at the given path.
var file = system.file.openDialog(1, "Documents");
tag.write("File", file); // Display the name of the file saved
system.ftp.download(Object config, Storage type, String sourcePath, String targetPath) Object config:
FTP server information
  • server: FTP server address.
  • port: FTP server port.
  • username (Optional): FTP server username.
  • password (Optional): FTP server password.


Storage type:
1: Storage.Local
2: Storage.Usb
3: Storage.SdCard
4: Storage.Ftp

String sourcePath:
Source file path

String targetPath:
Target file path

Returns:
Boolean value
Returns a boolean value, true (1) or false (0), if downloading Object config from the FTP server was successful.
This script will not work in the simulator.
let ftpConfig = {
    "server": "192.168.1.100",
    "port": 21,
    "username": "ftp",
    "password": "ftppass"
};
system.ftp.download(ftpConfig, Storage.Local, "/location", "/downloads/location");
system.ftp.startServer() Returns:
No return value
Start a local FTP server.
This script will not work in the simulator.
system.ftp.startServer();
system.ftp.stopServer() Returns:
No return value
Stop a local FTP server.
This script will not work in the simulator.
system.ftp.stopServer();
system.ftp.upload(Object config, Storage type, String sourcePath, String targetPath) Object config:
FTP server information
  • server: FTP server address.
  • port: FTP server port.
  • username (Optional): FTP server username.
  • password (Optional): FTP server password.


Storage type:
1: Storage.Local
2: Storage.Usb
3: Storage.SdCard
4: Storage.Ftp

String sourcePath:
Source file path

String targetPath:
Target file path

Returns:
Boolean value
Returns a boolean value, true (1) or false (0), if uploading Object config to the FTP server was successful.
This script will not work in the simulator.
let ftpConfig = {
    "server": "192.168.1.100",
    "port": 21,
    "username": "ftp",
    "password": "ftppass"
};
system.ftp.upload(ftpConfig, Storage.Local, "/location", "/downloads/location");
system.hasPermission(String permission) String permission:
Permission to check for

Returns:
Boolean value
Returns a boolean value, true (1) or false (0), if the currently logged-in user has the specified permission.
if(system.hasPermission("log")) {
  datalog.start("Changes"); 
  // Start the data log if user has permission
}
system.importScript(String scriptName) String scriptName:
Script to run

Returns:
No return value
Executes the specified script in the current project on the current thread.
system.importScript("Script");
system.login(String username, String password) String username:
Name of the user

String password:
Optional parameter Password of the user

Returns:
Boolean value
Returns a boolean value, true (1) or false (0), if the user could successfully log in to the Identity and Access Management feature.
if (system.login("Admin", "admin_Pass")) {
tag.write("Admin", 1); 
// Set admin logged in
tag.write("User", 0); 
// Set user logged out
}

else if (system.login("User")) { tag.write("User", 1); // Set user logged in tag.write("Admin", 0); // Set admin logged out }
system.logout() Returns:
No return value
Logs out the current user from the Identity and Access Management feature.
system.logout();
system.
openAuthWindow(Object properties)
Object properties:
Optional parameter
Conditions for authenticating a user
  • Username: User to authenticate.
  • Permissions: Allows users with the listed permissions to log in.


Returns:
Boolean value
Opens a dialog window to authenticate a user and returns a boolean value, true (1) or false (0), if the user could successfully log in.
If no user is provided, this will authenticate any user that enters their username and password.
If the user does not have the listed permissions, they will not be able to log in.
var properties = {username: "Admin", permissions: "Bypass"};
if(system.openAuthWindow
(properties)) {
tag.write("Bypass", 1); 
// Set the bypass tag to true
}
system.openConfig() Returns:
No return value
Opens the runtime configuration menu.
system.openConfig();
system.
openFrameMonitor()
Returns:
No return value
Opens the frame monitor window.
This script will not work in the simulator.
system.openFrameMonitor();
system.
openLoginWindow(Object properties)
Object properties: Optional parameter
Conditions for displaying available users or the user type
  • listUsers: Boolean value to display all available users or the user type.


Returns:
No return value
Opens the login window for the Identity and Access Management feature.
var prop = {listUsers: 1};
system.openLoginWindow(prop);
system.openLoginWindow();
system.runScript(String scriptName) String scriptName: Name of the script to run

Returns:
No return value
Executes the specified script in the current project on a separate thread.
system.runScript("Initialize");
system.screenshot(Storage type) Storage type:
2: Storage.Usb
3: Storage.SdCard

Returns:
No return value
Take a screenshot during runtime.
The screenshot will be stored in Storage type.
system.screenshot(Storage.Usb);
system.screenshot(3);
system.setDateTime(Date date) Date date:
Date and time to set on the Xpanel

Returns:
No return value
Sets the date and time on the Xpanel.
This script will not work in the simulator.
var day = Date.now();
system.setDateTime(day);
var now = new Date();
system.setDateTime(now);
system.setLanguage(String language) String language:
Language to be used by the String Table Editor

Returns:
No return value
Sets the language to be used by the String Table Editor.
This must match one of the columns in the String Table Editor.
system.setLanguage("English");
system.staticBeep(boolean enable) boolean enable:
0: false
1: true

Returns:
No return value
Plays a beeping sound from the built-in Xpanel buzzer.
This script does not work in the simulator.
system.staticBeep(1);
thread.msleep(50);
system.staticBeep(0);
system.video.playFile(Storage type, String path) Storage type:
1: Storage.Local
2: Storage.Usb
3: Storage.SdCard
4: Storage.Ftp
5: Storage.Project

String path: Video file path location

Returns:
No return value
Opens a video for playback from the specified path.
This script will not work in the simulator.
This will only work on the eXT2 series.
system.video.playFile
(Storage.Project, "Folder/safety.wav");
system.video.playFile(2, "safety.wav");
system.video.stop() Returns:
No return value
Stops the current video playback.
This script will not work in the simulator.
This will only work on the eXT2 series.
system.video.stop();

Tag

Function Parameters
and
Return Value
Description
and
Example
tag.read(String name) String name:
Name of the tag to read

Returns:
Data type of the tag
Gets the current value of the specified tag.
// Integer tag
if(tag.read("Counter") < 5) {
	// Do something
}
// Float tag
if (tag.read("Amount") > 1.93684) {
	// Do something
}
// String tag
if (tag.read("Input") != ("Hello")) {
	// Do something
}
tag.write(String name, Value value) String name:
Name of the tag to read

Value value:
Value to change the tag to

Returns:
No return value
Sets the value of the specified tag.
tag.write("Counter", tag.read("Counter") + 1);
// Increment "Counter" by 1
tag.writeBatch(Array tagNames, Array tagValues) Array tagNames:
Array of tag names to write to

Array tagValues:
Array of tag values to write

Returns:
No return value
Writes to multiple tags at once.
var tags = ["Tag 1", "Tag 2", "Tag 3"];
// Tag Array
var vals = [0, 100, "Hello"];
// Value Array
tag.writeBatch(tags, vals);
// Write command

Thread

Function Parameters
and
Return Value
Description
and
Example
thread.msleep(int msecs) int msecs:
Time in milliseconds

Returns:
No return value
Suspends the current thread for the specified time, in milliseconds, before resuming execution.
thread.msleep(300);
thread.sleep(int secs) int secs:
Time in seconds

Returns:
No return value
Suspends the current thread for the specified time, in seconds, before resuming execution.
thread.sleep(10);

JavaScript Scripts

The following scripts are built-in to the JavaScript language.

Array

Function Parameters
and
Return Value
Description
and
Example
Array.isArray(value) value:
The value to be checked

Returns:
Boolean value
Returns a boolean value, true (1) or false (0), if the parameter is an array.
Official documentation here.
var tags = ["t1", "t2", "t3"];
if (Array.isArray(tags)) {
	// Do something
}

Date

Function Parameters
and
Return Value
Description
and
Example
Date.now() Returns:
Number
Returns a number representing the timestamp, in milliseconds, of the current time.
Official documentation here.
system.setDateTime(Date.now());
Date.parse(dateString) dateString:
String in the date time String format
YYYY-MM-DDTHH:mm:ss:sssZ
  • YYYY: Year ranging from 0000 to 9999.
  • MM: Month ranging from 01 to 12 (default 01).
  • DD: Day ranging from 01 to 31 (default 01).
  • T: Literal character indicating time parameters (don't change).
  • HH: Hour ranging from 00 to 23 (default 00).
    24:00:00 is allowed as a special case indicating midnight.
  • mm: Minute ranging from 00 to 59 (default 00).
  • ss: Second ranging from 00 to 59 (default 00).
  • sss: Millisecond ranging from 00 to 59 (default 00).
  • z: Timezone offset.
    Can be the literal character z (indicating UTC), or + or - followed by HH:mm, the offset in hours and minutes from UTC.


Returns:
Number
Returns a number representing the timestamp of the given date.
If dateString is invalid, NaN (not a number) is returned.
Official documentation here.
var date = Date.parse("04 Dec 1995 00:12:00 GMT");
tag.write("Date", date);
Date.UTC(year, monthIndex, day, hours, minutes, seconds, milliseconds) year:
Integer value representing the year ranging from 0 to 99 mapping to the years 1900 to 1999


monthIndex:
Optional parameter Integer value representing the month ranging from 0 to 11 mapping to the years January to December (default 0)


day:
Optional parameter Integer value representing the day of the month ranging from 1 to 31 (default 1)


hours:
Optional parameter Integer value representing the hour of the day ranging from 0 to 23 (default 0)


minutes:
Optional parameter Integer value representing minutes ranging from 0 to 59 (default 0)


seconds:
Optional parameter Integer value representing seconds ranging from 0 to 59 (default 0)


milliseconds:
Optional parameter Integer value representing milliseconds ranging from 0 to 59 (default 0)


Returns:
Number
Returns a number representing the timestamp of the given date.
If the input parameter is invalid, NaN (not a number) is returned.
Official documentation here.
var date = new Date(Date.UTC(96, 1, 2, 3, 4, 5));
tag.write("Date", date);

Global Objects

Function Parameters
and
Return Value
Description
and
Example
decodeURI(encodedURI) encodedURI:
Complete, encoded Uniform Resource Identifier

Returns:
String
Returns a string representing the unencoded version of the given encoded Uniform Resource Identifier (URI).
Official documentation here.
var uri = "https://mozilla.org/?x=шеллы";
var encoded = encodeURI(uri);
notification.send(encoded);
// Expected output: "https://mozilla.org/?x=%D1%88%D0%B5%D0%BB%D0%BB%D1%8B"
decodeURIComponent(encodedURI) encodedURI:
An encoded component of a Uniform Resource Identifier

Returns:
String
Decodes a Uniform Resource Identifier (URI) component previously created by encodeURIComponent() and returns a string representation of the encoded URI component.
Official documentation here.
function containsEC(x) {
  // ie ?,=,&,/ etc
  return decodeURI(x) !== decodeURIComponent(x);
}
notification.send(
  containsEC("%3Fx%3Dtest"));
// ?x=test
// Expected output: true
notification.send(
  containsEC(
  "%D1%88%D0%B5%D0%BB%D0%BB%D1%8B"));
// шеллы
// Expected output: false
encodeURI(uri) uri:
String to be encoded as a URI

Returns:
String
Returns a new String representing the provided String encoded as a URI.
Official documentation here.
var uri = "https://mozilla.org/?x=шеллы";
var encoded = encodeURI(uri);
notification.send(encoded);
// Expected output: "https://mozilla.org/?x=%D1%88%D0%B5%D0%BB%D0%BB%D1%8B"
encodeURIComponent(uriComponent) uriComponent:
String to be encoded as a URI component

Returns:
String
Returns a new String representing the provided String encoded as a URI component.
Official documentation here.
// Encodes characters such as ?,=,/,&,:
notification.send(`?x=${encodeURIComponent("test?")}`);
// Expected output: "?x=test%3F"
notification.send(`?x=${encodeURIComponent("шеллы")}`);
// Expected output: "?x=%D1%88%D0%B5%D0%BB%D0%BB%D1%8B"
escape(str)
Deprecated
str:
String to be encoded

Returns:
String
Returns a new String in which certain characters have been escaped.
Official documentation here.
escape(str);
eval(script) script:
String representing a JavaScript expression, statement, or sequence of statements

The expression can include variables and properties of existing objects

Returns:
Completion value of evaluating the given code
Evaluates JavaScript code represented as a String and returns its completion value.
The source is parsed as a script.
Warning: Executing JavaScript from a string is an enormous security risk.
It is far too easy for a bad actor to run arbitrary code when you use eval().

Official documentation here.
notification.send(eval("2 + 2"));
// Expected output: 4
notification.send(eval(new String("2 + 2")));
// Expected output: 2 + 2
notification.send(eval("2 + 2") === eval("4"));
// Expected output: true
notification.send(eval("2 + 2") === eval(new String("2 + 2")));
// Expected output: false
isFinite(value) value:
Value to be tested

Returns:
Boolean value
Returns a boolean value, true (1) or false (0), if the specified value is not NaN, Infinity, or -Infinity.
Official documentation here.
function div(x) {
  if (isFinite(1000 / x)) {
    return "Number is NOT Infinity.";
  }
  return "Number is Infinity!";
}
notification.send(div(0));
// Expected output: "Number is Infinity!""
notification.send(div(1));
// Expected output: "Number is NOT Infinity."
isNaN(value) value:
Value to be tested

Returns:
Boolean value
Returns a boolean value, true (1) or false (0), if the specified value is NaN (not a number).
Official documentation here.
function milliseconds(x) {
  if (isNaN(x)) {
    return "Not a Number!";
  }
  return x * 1000;
}
notification.send
  (milliseconds("100F"));
// Expected output: "Not a Number!"
notification.send
  (milliseconds("0.0314E+2"));
// Expected output: 3140
parseFloat(string) string:
The value to parse, coerced to a String.

Leading whitespace in this argument is ignored.

Returns:
Float value
Returns a floating point number parsed from the given string or NaN (not a number) when the first non-whitespace character cannot be converted to a number.
Official documentation here.
function circumference(r) {
  return parseFloat(r) * 2.0 * Math.PI;
}
notification.send
  (circumference(4.567));
// Expected output: 28.695307297889173
notification.send
  (circumference("4.567abcdefgh"));
// Expected output: 28.695307297889173
notification.send
  (circumference("abcdefgh"));
// Expected output: NaN
parseInt(string)

parseInt(string, radix)
string:
String starting with an Integer

Leading whitespace in this argument is ignored.

radix:
Optional parameter
Integer between 2 and 36

Returns:
Integer value
Returns the integer parsed from the given string.
NaN (not a number) is returned when the radix is 2 > 32-bit integer radix or 36 < 32-bit integer radix, or the first non-whitespace character cannot be converted to a number.
Official documentation here.
notification.send(parseInt("123"));
// 123 (default base-10)
notification.send(parseInt("123", 10));
// 123 (explicitly specify base-10)
notification.send(parseInt("   123 "));
// 123 (whitespace is ignored)
notification.send(parseInt("077"));
// 77 (leading zeros are ignored)
notification.send(parseInt("1.9"));
// 1 (decimal part is truncated)
notification.send(parseInt("ff", 16));
// 255 (lower-case hexadecimal)
notification.send(parseInt("0xFF", 16));
// 255 (upper-case hexadecimal with "0x" prefix)
notification.send(parseInt("xyz"));
// NaN (input can't be converted to an integer)
unescape(str)
Deprecated
str:
String to be decoded

Returns:
String
Returns a new String in which certain characters have been unescaped.
Official documentation here.
unescape("abc123"); // "abc123"
unescape("%E4%F6%FC"); // "äöü"
unescape("%u0107"); // "ć"

JSON

Function Parameters
and
Return Value
Description
and
Example
JSON.parse(text)

JSON.parse(text, reviver)
text:
String to parse as JSON

reviver:
Optional parameter
If a function, this prescribes how each value originally produced by parsing is transformed before being returned.
  • key: The key associated with the value.
  • value: The value produced by parsing.
  • context (Optional): Context object that holds state relevant to the current expression being revived.
    • source: The original JSON String representing this value.


Returns:
Object, Array, String, number, Boolean, or null value
Parses a JSON string, constructing the JavaScript value or object described by the String.
Official documentation here.
var json = '{"result":true, "count":42}';
var obj = JSON.parse(json);
notification.send(obj.count);
// Expected output: 42
notification.send(obj.result);
// Expected output: true
JSON.stringify(value)

JSON.stringify(value, replacer)

JSON.stringify(value, replacer, space)
value:
The value to convert to a JSON String

reviver:
Optional parameter
Function that alters the behavior of the stringification process, or an array of Strings and numbers that specifies properties of value to be included in the output

space:
Optional parameter
String or number that's used to insert white space (including indentation, line break, etc.) into the JSON String for readability purposes

Returns:
JSON String
Converts a JavaScript value to a JSON String, optionally replacing values if a replacer function is specified or optionally including only the specified properties if a replacer array is specified.
An optional reviver function can be provided to perform a transformation on the resulting object before it is returned.
Official documentation here.
notification.send(JSON.stringify({ x: 5, y: 6 }));
// Expected output: '{"x":5,"y":6}'
notification.send([new Number(3), new String("false"), new Boolean(false)]),
);
// Expected output: '[3,"false",false]'
notification.send(JSON.stringify({ x: [10, undefined, function () {}, Symbol("")] }));
// Expected output: '{"x":[10,null,null,null]}'
notification.send(JSON.stringify(new Date(2006, 0, 2, 15, 4, 5)));
// Expected output: '"2006-01-02T15:04:05.000Z"'

Math

Function Parameters
and
Return Value
Description
and
Example
Math.abs(x) x:
A number

Returns:
Number
Returns the absolute value of x.
If x is negative or -0, it returns its opposite number: -x (non-negative).
The result is always positive or 0.
Official documentation here.
Math.abs(-Infinity); // Infinity
Math.abs(-1); // 1
Math.abs(-0); // 0
Math.abs(0); // 0
Math.abs(1); // 1
Math.abs(Infinity); // Infinity
Math.acos(x) x:
A number between -1 and 1 (inclusive) representing the angle's cosine value

Returns:
Number
Returns the inverse cosine (angle in radians between 0 and π, inclusive) of x.
If x is less than -1 or greater than 1, it returns NaN (not a number).
Official documentation here.
Math.acos(-2); // NaN
Math.acos(-1); // 3.141592653589793 (π)
Math.acos(0); // 1.5707963267948966 (π/2)
Math.acos(0.5); // 1.0471975511965979 (π/3)
Math.acos(1); // 0
Math.acos(2); // NaN
Math.asin(x) x:
A number between -1 and 1 (inclusive) representing the angle's sine value

Returns:
Number
Returns the inverse sine (angle in radians between -π/2 and π/2, inclusive) of x.
If x is less than -1 or greater than 1, it returns NaN (not a number).
Official documentation here.
Math.asin(-2); // NaN
Math.asin(-1); // -1.5707963267948966 (-π/2)
Math.asin(-0); // -0
Math.asin(0); // 0
Math.asin(0.5); // 0.5235987755982989 (π/6)
Math.asin(1); // 1.5707963267948966 (π/2)
Math.asin(2); // NaN
Math.atan(x) x:
A number

Returns:
Number
Returns the inverse tangent (angle in radians between -π/2 and π/2, inclusive) of x.
If x is Infinity, it returns π/2.
If x is -Infinity, it returns -π/2.
Official documentation here.
Math.atan(-Infinity); // -1.5707963267948966 (-π/2)
Math.atan(-0); // -0
Math.atan(0); // 0
Math.atan(1); // 0.7853981633974483  (π/4)
Math.atan(Infinity); // 1.5707963267948966  (π/2)
// The angle that the line (0,0) -- (x,y) forms with the x-axis in a Cartesian coordinate system
var theta = (x, y) => Math.atan(y / x);
Math.atan2(y, x) y:
Y coordinate of the point

x:
x coordinate of the point

Returns:
Number
Returns the angle in the plane (angle in radians between -π and π, inclusive) between the positive x-axis and the ray from (0, 0) to the point (x, y).
Official documentation here.
Math.atan2(90, 15); // 1.4056476493802699
Math.atan2(15, 90); // 0.16514867741462683
Math.ceil(x) x:
A number

Returns:
Number
Returns the smallest integer greater than or equal to x.
This is the same value as -Math.floor(-x).
Official documentation here.
Math.ceil(-Infinity); // -Infinity
Math.ceil(-7.004); // -7
Math.ceil(-4); // -4
Math.ceil(-0.95); // -0
Math.ceil(-0); // -0
Math.ceil(0); // 0
Math.ceil(0.95); // 1
Math.ceil(4); // 4
Math.ceil(7.004); // 8
Math.ceil(Infinity); // Infinity
Math.cos(x) x:
A number representing an angle in radians

Returns:
Number
Returns the cosine (angle in radians between 0 and π, inclusive) of x.
If x is Infinity, -Infinity, or NaN, it returns NaN (not a number).
Official documentation here.
Math.cos(-Infinity); // NaN
Math.cos(-0); // 1
Math.cos(0); // 1
Math.cos(1); // 0.5403023058681398
Math.cos(Math.PI); // -1
Math.cos(2 * Math.PI); // 1
Math.cos(Infinity); // NaN
Math.exp(x) x:
A number

Returns:
Number
Returns a non-negative number representing ex, where e is the base of the natural logarithm.
If x is Infinity, -Infinity, or NaN, it returns NaN (not a number).
Official documentation here.
Math.exp(-Infinity); // 0
Math.exp(-1); // 0.36787944117144233
Math.exp(0); // 1
Math.exp(1); // 2.718281828459045
Math.exp(Infinity); // Infinity
Math.floor(x) x:
A number

Returns:
Number
Returns the largest integer less than or equal to x.
This is the same value as -Math.ceil(-x).
Official documentation here.
Math.floor(-Infinity); // -Infinity
Math.floor(-45.95); // -46
Math.floor(-45.05); // -46
Math.floor(-0); // -0
Math.floor(0); // 0
Math.floor(4); // 4
Math.floor(45.05); // 45
Math.floor(45.95); // 45
Math.floor(Infinity); // Infinity
Math.log(x) x:
A number greater than or equal to 0

Returns:
Number
Returns the natural logarithm (base e) of x.
If x is ±0, it returns -Infinity.
If x is less than 0, it returns NaN.
Official documentation here.
Math.log(-1); // NaN
Math.log(-0); // -Infinity
Math.log(0); // -Infinity
Math.log(1); // 0
Math.log(10); // 2.302585092994046
Math.log(Infinity); // Infinity
Math.max()

Math.max(value1)

Math.max(value1, value2)

Math.max(value1, value2, ..., valueN)
value:
Optional parameters
Zero or more numbers among which the largest value will be selected and returned

Returns:
Number
Returns the largest of the given numbers.
Returns NaN if any of the parameters is or is converted into NaN (not a number).
Returns -Infinity if no parameters are provided.
Official documentation here.
Math.max(10, 20); // 20
Math.max(-10, -20); // -10
Math.max(-10, 20); // 20
Math.min()

Math.min(value1)

Math.min(value1, value2)

Math.min(value1, value2, ..., valueN)
value:
Optional parameters
Zero or more numbers among which the smallest value will be selected and returned

Returns:
Number
Returns the smallest of the given numbers.
Returns NaN if any of the parameters is or is converted into NaN (not a number).
Returns Infinity if no parameters are provided.
Official documentation here.
Math.min(10, 20); // 10
Math.min(-10, -20); // -20
Math.min(-10, 20); // -10
Math.pow(base, exponent) base:
The base number

exponent:
The exponent number

Returns:
Number
Returns a number representing base taken to the power of exponent.
Returns NaN (not a number) in the following cases:
  • exponent is NaN.
  • base is NaN and exponent is not 0.
  • base is ±1 and exponent is ±Infinity.
  • base < 0 and exponent is not an integer.

Official documentation here.
Math.pow(7, 2); // 49
Math.pow(7, 3); // 343
Math.pow(4, 0.5); // 2 (square root of 4)
Math.pow(8, 1 / 3); // 2 (cube root of 8)
Math.pow(7, -2); // 0.02040816326530612 (1/49)
Math.pow(8, -1 / 3); // 0.5
Math.pow(-7, 2); // 49 (squares are positive)
Math.pow(-7, 0.5); // NaN (negative numbers don't have a real square root)
// Due to "even" and "odd" roots laying close to each other,
// and limits in the floating number precision,
// negative bases with fractional exponents always return NaN,
// even when the mathematical result is real
Math.pow(-7, 1 / 3); // NaN
Math.pow(0, 0); // 1 (anything ** ±0 is 1)
Math.pow(Infinity, 0.1); // Infinity (positive exponent)
Math.pow(NaN, 0); // 1
Math.pow(NaN, 1); // NaN
Math.pow(1, NaN); // NaN
Math.random() Returns:
Floating-point, pseudo-random number
Returns a floating-point, pseudo-random number between 0 (inclusive) and 1 (exclusive).
Official documentation here.
function getRandom() {
  return Math.random();
}
Math.round(x) Returns:
A number

Returns:
Number
Returns the value of x rounded to the nearest integer.
Official documentation here.
Math.round(-Infinity); // -Infinity
Math.round(-20.51); // -21
Math.round(-20.5); // -20
Math.round(-0.1); // -0
Math.round(0); // 0
Math.round(20.49); // 20
Math.round(20.5); // 21
Math.round(42); // 42
Math.round(Infinity); // Infinity
Math.sin(x) x:
A number representing an angle in radians

Returns:
Number
Returns the sine (angle in radians between -1 and 1, inclusive) of x.
If x is Infinity, -Infinity, or NaN, it returns NaN (not a number).
Official documentation here.
Math.sin(-Infinity); // NaN
Math.sin(-0); // -0
Math.sin(0); // 0
Math.sin(1); // 0.8414709848078965
Math.sin(Math.PI / 2); // 1
Math.sin(Infinity); // NaN
Math.sqrt(x) x:
A number greater than or equal to 0

Returns:
Number
Returns the square root of x, a non-negative number.
If x < 0, it returns NaN (not a number).
Official documentation here.
Math.sqrt(-1); // NaN
Math.sqrt(-0); // -0
Math.sqrt(0); // 0
Math.sqrt(1); // 1
Math.sqrt(2); // 1.414213562373095
Math.sqrt(9); // 3
Math.sqrt(Infinity); // Infinity
Math.tan(x) x:
A number representing an angle in radians

Returns:
Number
Returns the tangent of x.
If x is Infinity, -Infinity, or NaN, it returns NaN (not a number).
Official documentation here.
Math.tan(-Infinity); // NaN
Math.tan(-0); // -0
Math.tan(0); // 0
Math.tan(1); // 1.5574077246549023
Math.tan(Math.PI / 4); // 0.9999999999999999 (Floating point error)
Math.tan(Infinity); // NaN

Object

Function Parameters
and
Return Value
Description
and
Example
Object.create(proto)

Object.create(proto, propertiesObject)
proto:
The object which should be the prototype of the newly-created object

propertiesObject:
Optional parameter
If specified and not undefined, an objet whose enumerable own properties specify property descriptors to be added to the newly-created object, with the corresponding property names.

Returns:
Object
Creates a new object using an existing object as the prototype of the newly created object.
Official documentation here.
var person = {
  isHuman: false,
  printIntroduction: function () {
    console.log(`My name is ${this.name}. Am I human? ${this.isHuman}`);
  },
};
var me = Object.create(person);
me.name = "Matthew"; 
// "name" is a property set on "me", but not on "person"
me.isHuman = true; 
// Inherited properties can be overwritten
me.printIntroduction();
// Expected output: "My name is Matthew. Am I human? true"
Object.defineProperties(obj, props) obj:
The object on which to define or modify properties

props:
Object whose keys represent the names of properties to be defined or modified and whose values are objects describing those properties
  • configurable: True if and only if the type of this property descriptor may be changed and if the property may be deleted from the corresponding object (default false).
  • enumerable: True if and only if this property shows up during enumeration of the properties on the corresponding object (default false).
  • value (Optional): The value associated with the property (default undefined).
  • writable (Optional): True if an only if the value associated with the property may be changed with an assignment operator (default false).
  • get (Optional): Function which serves as a getter for the property or undefined if there is no getter (default undefined).
  • set (Optional): Function which serves as a setter for the property or undefined if there is no setter (default undefined).


Returns:
Object
Defines new or modifies existing properties directly on an object, returning the object.
Official documentation here.
var object1 = {};
Object.defineProperties(
  object1, 
  {
    property1: {
      value: 42,
      writable: true,
  },
  property2: {},
});
notification.send
  (object1.property1);
// Expected output: 42
Object.defineProperty(obj, prop, descriptor) obj:
The object on which to define or modify properties

prop:
String or Symbol specifying the key of the property to be defined or modified

descriptor:
The descriptor for the property being defined or modified

Returns:
Object
Defines a new property directly on an object, or modifies an existing property on an object, and returns the object.
Official documentation here.
var object1 = {};
Object.defineProperty(
  object1, 
  "property1", {
    value: 42,
    writable: false,
});
object1.property1 = 77;
// Throws an error in strict mode
notification.send
  (object1.property1);
// Expected output: 42
Object.
getOwnPropertyDescriptor(obj, prop)
obj:
The object in which to look for the property

prop:
Name or Symbol of the property whose description is to be retrieved

Returns:
Object
Returns an object describing the configuration of a specific property on a given object.
Official documentation here.
var object1 = {
  property1: 42,
};
var descriptor1 = Object.
  getOwnPropertyDescriptor(
    object1, 
    "property1");
notification.send
(descriptor1.configurable);
// Expected output: true
notification.send
  (descriptor1.value);
// Expected output: 42
Object.getPrototypeOf(obj) obj:
The object whose prototype is to be returned

Returns:
Prototype
Returns the prototype of the specified object or null.
Official documentation here.
var prototype1 = {};
var object1 = Object.create(prototype1);
notification.send
  (Object.getPrototypeOf
    (object1) === prototype1);
// Expected output: true
Object.keys(obj) obj:
An object

Returns:
Array
Returns an array of a given object's own enumerable string-keyed property names.
Official documentation here.
var object1 = {
  a: "somestring",
  b: 42,
  c: false,
};
notification.send
  (Object.keys(object1));
// Expected output: Array ["a", "b", "c"]
Object.preventExtensions(obj) obj:
The object which should be made non-extensible

Returns:
Object
Prevents new properties from ever being added to an object.
It also prevents the object's prototype from being reassigned.
Official documentation here.
var object1 = {};
Object.preventExtensions
  (object1);
try {
  Object.defineProperty(
    object1, 
    property1", {
      value: 42,
  });
} catch (e) {
  notification.send(e);
// Expected output: TypeError: Cannot define property property1, object is not extensible
}

String

Function Parameters
and
Return Value
Description
and
Example
String.fromCharCode()

String.fromCharCode(num1)

String.fromCharCode(num1, num2)

String.fromCharCode(num1, num2, ..., numN)
num:
Optional parameters
Number between 0 and 65,535 (0xFFFF) representing a UTF-16 code unit
Numbers greater than 0xFFFF are truncated to the last 16 bits

Returns:
String
Returns a String created from the specified sequence of UTF-16 code units.
Official documentation here.
notification.send
(String.fromCharCode(189, 43, 190, 61));
// Expected output: "½+¾="