Promotic

SetExpr - method of the PmExpr object

Description:
Sets an expression in the form of a text string.
Syntax:
Boolean SetExpr(String sExpr)
Parameters:
sExpr(String) Text expression in JavaScript syntax. For example:
"a+b"
"bbb + 10 * oDat.Item('Temperature').Value"
etc.
Return value:
The method validates the syntax of entered expression. It does not check whether all the variables used in the expression have been defined (therefore the SetVar can be called after this method has already been called).
true - on success
false - on error
Note:
This method is also functional in Web panels.

This method just sets the expression into the PmExpr object so it can be later quickly evaluated. The evaluation itself can then be executed by the Eval method.
See also:
- PmExpr.SetVar (method)
- PmExpr.Eval (method)
Example1:
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();

History:
Pm8.03.20: Created
PROMOTIC 9.0.27 SCADA system documentation MICROSYS, spol. s r.o.

Send page remarkContact responsible person
© MICROSYS, spol. s r.o.