Promotic
WikipediaLinkedInYoutubeTwitterFacebook

Object PmExpr (Evaluation tool of JavaScript expression)

Description:
Object allows evaluation of JavaScript expression entered as String.
Properties and methods:
SetVar Adds one variable into the object
SetExpr Sets an expression in the form of a text string
Eval Evaluation of entered expression
Note:
- The object can be created by the method Pm.CreatePmExpr.
- This object is functional also in Web panels.
 
The expression can be added into the object by SetExpr. This expression can contain names of variables. These variables can be added into the object by the SetVar method. The Eval method then evaluates the expression (including variables) and returns the result.
 
Evaluation of expression by means of the PmExpr object is useful for example if the expression is read as a string (e.g. from file, from the communication ...) meaning that the final form ofthe expression is previously unknown.

For example the application for general data evaluation needs to have the data processing expressions to be located in a configuration text file.

Examples of expression evaluation by PmExpr object:
Evaluation of simple expression "a+b":
JavaScriptVBScriptSelect and copy to clipboard

var val;
var oExpr = Pm.CreatePmExpr();
oExpr.SetExpr("a+b");
oExpr.SetVar("a", 3);
oExpr.SetVar("b", 2.5);
val = oExpr.Eval();  //In the val variable there will be the value 5.5
Evaluation of expression using the PmaData object:
JavaScriptVBScriptSelect and copy to clipboard

var val;
var oExpr = Pm.CreatePmExpr();
oExpr.SetExpr("10 * oDat.Item('Temperature').Value");
oExpr.SetVar("oDat", pMe.Pm("/Boiler1/Data"));
val = oExpr.Eval();  //In val variable there will be the value 10times bigger then the value of temperature in the PmaData object

History:
Pm8.03.20: New auxiliary object for evaluation of JavaScript expressions in the form of text. There is a new preconfiguration as example of functionality: / Panels (PmaPanel) / Others examples / PmExpr - mathematical expression.
PROMOTIC 9.0.7 SCADA system documentation - MICROSYS, spol. s r.o.

Send page remarkContact responsible person
© MICROSYS, spol. s r. o.Tavičská 845/21 703 00 Ostrava-Vítkovice