Promotic
WikipediaLinkedInYoutubeTwitterFacebook

Object PmMap (Object with named values)

Description:
In this object it is possible to add and use named values (i.e. the dynamic properties) by script.

At the start (after being created by the Pm.CreatePmMap method) the object is empty and contains only built-in methods starting with map (e.g. mapLoadFromString).

Properties and methods:
Dynamic propertiesDynamic properties added by designer in the script. The names must not contain empty spaces, special characters, diacritics, must not begin with number or map characters.
mapAdd Sets multiple values of selected object properties
mapGetValueAt Returns a value of selected object property
mapSetValueAt Sets the value of selected object property
mapLoadFromString Creates properties with defined values in the object
mapSaveToString Saves the content of the object into string
mapGetPropNames Returns array containing names of all dynamic properties
Note:
- The object can be created by the method Pm.CreatePmMap.
- This object is functional also in Web panels.
- The object can be used in both VBScript and JavaScript languages.
 
Create property and set value:

In this object it is possible to create new properties with given name and value (contrary to other objects). New property is created by first write. For example:

JavaScriptSelect and copy to clipboard

var oMap = Pm.CreatePmMap();
oMap.xyz = 3.14;
In the oMap object, there is a new property "xyz" containing the value 3.14. Assigning new value to this property only changes the value of this property.

Properties in this object can also be created or set by the mapLoadFromString or mapSetValueAt method.

Caution: In the Web panel that is written in VBScript language it is not possible to create property just by assigning the value. In this case the mapSetValueAt method can be used.

 
Read property value:
JavaScriptSelect and copy to clipboard

var val = oMap.xyz;

Poperty value in this object can also by read by the mapGetValueAt method.


Comparison of objects used for data storage:

The following object types can be used for holding values (of any data type). Each of these objects has certain advantages and disadvantages and the choice depends on the desired usage.

PmArray: This object contains values that are accessible by index in the array - it is possible to read any value at any time in this object. Reading and setting values is very fast, but adding is slow.

This object is functional only for JavaScript language. For the VBScript language the array is represented by Array data type.

PmMap: This object contains values that are addressed by name (text identifier). Value names represent object properties. The advanatege is the "clarity" of usage in the script code. The disadvantage is the inability to access the values in cycle by index.
PmBuffer: This object contains binary values in data block. For reading/writing of individual value it is necessary to know its position (offset) in the data block and also the data type (size).

History:
Pm8.03.04: This object allows the application designer to create new user properties in this (empty) object. This is very handy if the designer needs to transfer multiple named values into some method.
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