$ObjRunMethod

Run the methods of an ActiveX object.

Syntax

$ObjRun[Method] (Object, MethodName, Ā«ParametersĀ»)

Parameters

Object

an object variable or formfield of type OLE

MethodName

a string or an expression that evaluates to a string

Parameters

one or more optional arguments as per the specifications of the object

Return Value

Returns a result as per the specification of the object.

Note: Zim attempts to convert to the assigned type. Ensure a proper variable type is assigned.

Comments

Parameters can be named. If they are named, they do not need to be entered in any particular order. Named parameters contain the name of the parameter, an equal sign, and the value of the parameter.

$null can be used to maintain position of optional parameters in unnamed argument list. Unnamed parameters must precede named parameters in argument list.

If you require it, you can have OLE objects return values by reference, since ZIM passes all variables by reference to OLE objects.

Example

The add method of Treeview is described as having the following syntax:

INode* Add(
      [in, optional] VARIANT* Relative,
      [in, optional] VARIANT* Relationship,
      [in, optional] VARIANT* Key,
      [in, optional] VARIANT* Text,
      [in, optional] VARIANT* Image,
      [in, optional] VARIANT* SelectedImage);

Assume you have a form called treeview with a treeview component on it called tree.

Assume vNode is a variable of type object. The syntax to add a node to the treeview's nodes object is provided below.

compute all myset wh $distinct (custs.cc) is not $null evaluate \
 ( let vNode = $ObjRunMethod ( vNodes, 'Add', \
    \ % placeholder for relative
    \ % placeholder for relationship
    $squeeze('', 'c',$trim(custs.cc)), \ %unnamed argument for Key
    $squeeze('','text=',$trim(custs.company)))) %named argument for Text

Assume the variables sWidth and sHeight are integers and the variable vole is an object. The following example retrieves the object's width and height given a display with two months high and three months wide:

let vole = $ObjCreate("mscomctl2.monthview.2")
out $ObjRunMethod(vole,"ComputeControlSize",3,2,sWidth,sHeight)

 

Related Topics