Promotic

Methods - tab of the PmaObject object

Description:
On this tab the designer's methods of this object are defined.
Buttons:
NewOpens the "Method" configuration window, where new method can be added.
DeleteDeletes the marked method
EditOpens the "Method" configuration window, where the marked method can be edited.
Note:
Further methods can be added to the object on this tab. Correct usage of these methods very simplifies and makes the application more readable.
An example of the usage: Imagine the folder PmaFolder that represents a device (e.g. Boiler). Sometimes it is necessary to detach this Boiler. It can be done so that in another folder there is detailed algorithm how to detach the Boiler but much better is to create the method directly in the Boiler object where the algorithm for the outage is placed. Then from the other folder this method is just called.

Any number of methods can be defined on this tab. A definition of just one method can be found on each line of the list (that is on the left up). These methods can be then called by the PmaObject.Methods or Pm.Methods property.
Method parameters:
pMe(Object) Reference to the Pma object, where the method is defined.
pResult[for write only] (Variant) Output parameter that is used for method output value.
Available only for methods written in the VBScript language. For JavaScript languagethe return value is set in return statement.
pContext(Object) (for PmaRoot and PmaPanel objects) reference to the object containig additional information about method calling conditions.
pContext.User - (Object) property with referrence to the PmUser object, containing detailed information about the user (local or network), that called the method. It can be used for example:
- for protecting the method for specific logged user or user group.
- for storing and reading the private user state data by methods SetPrivateData and GetPrivateData.

Caution! In order to keep the subobject User value trustworthy it is necessary to exclude the pseudo-groups $ANY and $ANY_NET from the appropriate permission WebRead (i.e. to ensure that the user is logged in when opening the Web page).
pContext.Language - (String) it returns the information about the national language, to be used for text outputs of the method (suitable especially when calling the method from Web panels). Language is determined with a text identifier, e.g. "en", "de", "ru" etc. - see Fully supported languages in the PROMOTIC system. See the "Main language of runtime" configurator.
pContext.TypeEnable - (Long) A permission type of client method calling. The designer can (according to the user setting, password or the computer address) disable the operation.
Setting this parameter is recommended only for special cases. Common security setting is better to be done by standard means of the permissions: WebMethods.
Caution! The property is functional only for Web panels.
1 (default) - enabling operation.
-1 - required log-on of the user (if the user hasn't been set) or disabling the user (if the user has been set but the name and password are wrong).
-2 - disabling operation for the client unconditionally.
Parameters defined by designer(Variant) It is used as passed parameters when calling the method. These parameters are defined in the "Parameters" configurator.
The methods defined on this tab for the PmaPanel object (panel methods) and for the PmaRoot object (global application methods) can be called even in the scripts of panels that are meant for Web sharing.

A list of used methods together with each method launch count can be seen in the INFO system in specific object view tab. The selected method can also be launched on this tab (only if the method does not include the parameters) after selecting from the local menu (by the right mouse button). See "PmaRoot > Permissions > InfoEdit" permission.

Caution! For the PmaPrototype object, the method is transferred into the PmaInstance object at application launch, if a method with this name does not already exist in the PmaInstance object.
Example1:
In the PmaFolder object there is the PmaData object (named "DAT") that contains several variables (with the names, for example "data1", "data2", etc.) Let's create simple method in the PmaFolder object named "dataadd" with one parameter (named "par1") that represents a name of the variable. The method returns the value of the requested variable increased by 10.
JavaScriptVBScriptSelect and copy to clipboard

var val = pMe.Pm("DAT").Item(par1).Value;
return val + 10;
We can call this method anywhere:
JavaScriptVBScriptSelect and copy to clipboard

var n = oFolder.Methods.dataadd("data1");
Example2:
Test whether the user calling the method is a member of $ADMIN group:
JavaScriptVBScriptSelect and copy to clipboard

if (pContext.User.Type == 2 && Pm.TestUserInGroup(1, "$ADMIN", pContext.User.Id))
{
// ...
}
Example3:
Calling the global method GetStartTime (it means defined in the PmaRoot object) with the par1 parameter (this way the method can be called in the application and also in the Web panel):
JavaScriptVBScriptSelect and copy to clipboard

var val = Pm.Methods.GetStartTime(par1);
Next examples:
See examples in the description of the PmaObject.Methods property.

History:
Pm9.00.25: This tab was also added into the PmaPrototype object.
Pm8.03.00: Now this tab is present in each Pma object and Pmg object (only some specific Pma object had it before).
Pm8.00.08: and Events the "Test" buttons was removed (used for script syntax checking) and also the "Edit" button (for expanding the script editor window to fullscreen). These functions were moved to the local menu in the script editor.
Pm8.00.00: Application global methods (i.e. the methods defined on the "Methods" tab of the PmaRoot object) can no longer (in default mode) be called directly by their name, but are now called by means of the Pm.Methods property. The reason is the limitation of the direct calling - for example it is not functional for Web panels. The old way of method calling (i.e. direct calling by method name) can still be used, but to od so, the #pragma option OldGlobalMethodCall script directive with the value 1 (flag of old method calling) must be used. When transforming current applications into PROMOTIC 8 a conversion will be done: the directive will be added into all global methods making the application fully functional.
PROMOTIC 9.0.27 SCADA system documentation MICROSYS, spol. s r.o.

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