CallAxMethod - method of the Pm object
Description:
Allows calling ActiveX object methods from JavaScript (input/output parameters, VBArray, etc.). ActiveX uses VBScript data types and conventions, but this method adapts JavaScript to be usable..
Syntax:
Variant CallAxMethod(String sReserved, Object oAxObject, String sAxMethod, Variant arglist)
Parameters:
sReserved | (String) Reserved. An empty string ("") must be here. |
---|
oAxObject | (Object) Reference to ActiveX object. |
---|
sAxMethod | (String) Name of called method. |
---|
arglist | (Variant) A variable number of parameters follows. These parameters are passed to the method called in the ActiveX object. The parameters are are passed as input paramater value. If there is PmArray among these paramaters then this array is automatically converted into VBArray. |
---|
Return values:
The value returned by called ActiveX method. If the ActiveX returned
VBArray then this array is automatically converted into
PmArray.
Note:
This method
is not functional in
Web panels.
VBScript and
ActiveX support input/output parameters while
JavaScript does not support such parameters. The
CallAxMethod method allows passing of input/output parameter to the
ActiveX method by auxiliary
PmMap object as follows:
1) The
PmMap auxiliary object is created.
2) The property
ParValue in the auxiliary object is set to the first value of the input parameter If the passed value must be of certain type (integer, byte, single), then the
ParType property can be used in the auxiliary object to define the data type of the input parameter. (both steps 1 and 2 can be completed together by the
PmMap.mapAdd method).
3) The reference to the auxiliary object is passed insted of the original parameter by calling the CallAxMethod method.
4) The output parameter value is read from the property ParValue.
Caution! If the input parameter is represented by PmArray then this array is automatically converted into VBArray. If the output parameter is represented by VBArray then this array is automatically converted into PmArray.
Example:
The example of calling the "
DBGetInfo" method of the
AtouchX object for communication with PLC devices
AMiT, where the requested input/output value (
mInfo) is of the
VBArray type.
JavaScriptSelect and copy to clipboard
var oApp = pMe.Pm("../AtouchApp").Acx;
var mInfo = Pm.CreatePmMap();
mInfo.ParValue = Pm.CreatePmArray().Create(5);
var nState = Pm.CallAxMethod("", oApp, "DBGetInfo", nWID, mInfo);
Pm.Debug("return INFO : " + mInfo.ParValue);