Promotic

Macro expression $.expr

This macro expression returns the evaluated expression written in JavaScript syntax.

Syntax:
$.expr("expression")
where "expression" may contain:
- Constant: Numeric (e.g. 1, 3.14) or string (e.g. '.mdb', 'Pressure').
Caution! String constants must be written with simple quotation marks (if doubled quotation marks were used for the whole expression), or backslash \" must be written before the quotation marks.
- Other macros: It is also possible to access for example Parameters of the Pma object, Parameters of the Pmg object, paths to files, values in the configuration file, etc.
- pMe variable: Represents Pma object or Pmg object - according to the object where the macro is defined.
The pMe can then be used for accessing properties or methods.
Caution! This variable is not functional for Web panels and in data extension.
- pDE variable: Only for data extensions where it substitutes the pMe variable.
Represents the scripting interface of data extension, see Data extensions.
The pDE.Var property (for example ExtAlarmAnalog.Var) returns the PmVar object, containing the data extension, accessible.
- pVar variable: Only for data extensions where it substitutes the pMe variable.
Represents the scripting interface of data extension, see Data extensions.
The pVar property (for example ExtAlarmAnalog.Var) returns the PmVar object, containing the data extension, accessible.
- Pm variable: Represents the Pm object.
Caution! This is a special, limited version of the Pm object that allows to use its mathematical, string, array, date and time, etc. However the functions related to the application itself or to the PROMOTIC system are not available (e.g. the logged-in user, application priority, launch date, calling global methods, etc.).
Example1:
The xx parameter value is 3. Then the evaluated expression equals to 13yy (not 4yy) because of the string summation.
The value of the parameter ($.par) always returns a value of type String.
JavaScript always executes the + operation as a string summation if there is at least one string among the operands.
The mathematical sumation is executed only if both operands are of the numeric type (see Example2).
$.expr("1+$.par('xx',0)+'yy'")
Example2:
The xx parameter value is 3. Then the evaluated expression equals to 4yy because of the mathematical summation.
The value of the parameter ($.par) always returns a value of type String that is converted by means of the Pm.ToNumber method into a number.
JavaScript executes the + operation as a mathematical summation because both operands are of the numeric type (contrary to Example1).
$.expr("1+Pm.ToNumber($.par('xx',0))+'yy'")
Example3:
Path to the Access database file (.mdb) used by the PmaTrendGroup object.
The file name is identical with the identification name of trends group (see PmaTrendGroup.GroupId property).
$.path("data",$.expr("'trend/'+pMe.GroupId+'.mdb'"))

Configurators in extended value editor:
JavaScript expressionExpression written in JavaScript syntax

History:
Pm9.00.07: The pVar variable can be used in the expression (object of the PmVar type).
Pm8.02.05: The pDE variable (object of the Data extensions type) can be used in the expression.
Pm8.02.00: Created
PROMOTIC 9.0.27 SCADA system documentation MICROSYS, spol. s r.o.

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