Variable Functions

Variable functions are used to read/write variables defined in the inSCADA Platform with script expression.

Variable Object: A JSON object returned by variable functions. It contains the time stamp and value.


Get Variable Value

object ins.getVariableValue(var variablename)

Reads the value of a variable defined in inSCADA.

variablename : String

Return Value: Returns the Variable object. If the value returned is "null", it means the operation failed. Variable could not be read.


var variable=ins.getVariableValue("UNIT01_Active_Power");
if (variable!==null) {
    if (variable.value>0) {
        ins.notify("info","Unit 01","Unit 1 is working");
    return variable.value;
return -1;

Get Variable Previous Values

object ins.getVariableValue(var variablename,var index)

Reads the value of a variable defined in inSCADA from previous scans. inSCADA stores the last 10 readings of the variables. You can reach these 10 values with index.

variablename : String

Return Value: Returns the Variable object. If the value returned is "null", it means the operation failed. Variable could not be read.


var variable=ins.getVariableValue("UNI01_Active_Power");
if (variable===null) {return -1}
var prv_variable=ins.getVariableValue("UNIT01_Active_Power",1);
if (prv_variable===null) {return -1}
if (variable.value!==prv_variable.value) {
    ins.notify("info","Unit 01","Power value is changed");
return variable.value;

Get Variables Values

Array[] ins.getVariableValues(var variablenames[])

Reads the values of the requested variable list defined in inSCADA.

variablenames[] : String array

Return Value: Returns an array of objects of the requested variables.



var VALUES=ins.getVariableValues(TAGS);
if (VALUES===null) {return -1;}

var mass_flow_rate_value=VALUES[1].value;
var mass_flow_rate_timestamp=VALUES[1].date;

Get Project Variables

object ins.getProjectVariableValues()

Reads the value of all variables connected to the project in inSCADA .

Return Value: Returns a JSON object with all variables and values for the project.


var result=ins.getProjectVariableValues();
if (result!==null) {
return -1;

Set Variable Value

ins.setVariableValue(String variablename, object value)

Writes a value to a variable defined in inSCADA.

variablename: The name of the variable to write the value to.



Set Variables Values

ins.setVariableValues(object variables)

Writes values to variables defined in inSCADA at once.

variables: A JSON object containing variables and the values to be written.

ins.setVariableValues, unlike ins.setVariableValue, allows values to be written to more than one variable at a time. When doing this, it optimizes the writing process in accordance with the protocol and sends the values in the same data block to the connected device at one time. A function that can be used to transfer multiple data.



Map Variable Value

ins.mapVariableValue(String source, String destination)

Writes a variable value to another variable.

Source: The variable name of the value to be read. A source variable.

Destination: Name of the variable to be write the value. A target variable.



ins.mapVariableValue(String source, String destination, var defaultvalue)

If the source variable cannot be read, it writes a default value to the target variable.


Last updated