In nSCADA you can write expressions in javascript. Unlike scripts, expressions can take parameters from the environment in which they are used. Environments they are used;

  • Variable Expression,

  • Variable Logs,

  • Alarms,

  • Alarm Group On-Off-Ack Actions,

  • Animation Elements,

Expressions are not project dependent. Expressions you write can be used in all projects.

Variable Expression

Variable expression is executed during the read, scan of a variable's communication channel. The expression you add to a variable is executed based on the scan period of the Device and Frame to which the Variable is connected.

Variables passed to Expression;

  • initialValue (Number)

  • self (object)

As shown in Figure 2, a custom Expression is written in a Variable. In the Expression definition above, we mentioned that you can get parameters from the environment where the Expressions are executed. When you examine the javascript code written in the example in Figure 2, you will see a variable named "initialValue". The variable "initialValue" is a variable that can only be used in Variable, sent to Expression by the inSCADA platform. This variable contains the value of the corresponding Variable.

if (initialValue<10) {
    return 1;
    return 0;

If you examine the javascript code in Figure 2, it is provided that if the corresponding variable value is less than 10, it will be 1 and if it is greater than or equal will be 0.

Variable Expression is a very powerful and useful feature. In traditional methods, you need to create virtual Variables / Tag for more complex and different calculations of raw data read from devices, then write scripts and process and copy the raw value from Variables / Tags where you read the raw value. However, inSCADA does not allow you to fill your project with untraceable content for such operations. It offers you a more powerful and useful Variable Expression method.

Below are different examples of variable expressions.

// Joule to KCal
var newValue=initialValue/4185.5;
return newValue;
if ("BAR">=0) {
return initialValue*1000; // Convert BAR to mBAR

if ("PSI">=0) {
return initialValue*69; // Convert PSI to mBAR
var datetime=new Date(initialValue);
if ("YEAR")>=0 {
return datetime.getYear()+1900;

if ("MONTH")>=0 {
return datetime.getMonth()+1;

Variable Logs

Expressions written in variable logs allow the variable value to be saved to the database during the scan period when the result is true.

Below are examples of expression that can be used in variable log.

if initialValue>100 return true; else false;
if ("DAILY")>=0 {
    if (dt.getHours()===0 && dt.getMinutes()===0) {
    return true; }
return false;

Last updated