Object PmExpr (Evaluation tool of JavaScript expression)

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
- The object can be created by the method Pm.CreatePmExpr.
- This object is functional also for Web panels. It is not functional in InternetExplorer8 and lower.
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 SetVar method. The Eval method then evaluates the expression (including the defined variables) and returns the result.
Evalueation of expression by the PmExpr object is useful for example if the expression is read as a string (e.g. from file, from communication ...) meaning that the final form ofthe expression is previously unknown. For example the applications 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.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 PmData object:
VBScriptSelect and copy to clipboard

Dim val, oExpr
Set 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 PmData object
PROMOTIC 8.3.23 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