Contents Previous Next Subchapters

Invoking a COM Server Method
Syntax coinvoke(method name)
method namemethod arguments)
See Also cocreate , copropget

Calls a method in the current object specified by the character row vector method name. The specified method must exist in the current object. See the O-Matrix cowith and coendwith functions for an explanation of navigating object model hierarchies. If present, method arguments may be integer, real, or double precision matrices, logical scalars, or character row vectors. The values of method arguments are passed to method name.

If the specified method name does not return a result, the result of coinvoke will be the O-Matrix constant novalue. If method name does return a result, the value created by coinvoke will be an integer, real, or double precision matrix, a logical scalar, or character row vector.


A Method With Arguments That Returns a Result
The Excel Application object provides a method CentimetersToPoint to convert a scalar from centimeters to points. If, at the O-Matrix prompt you enter
     coinvoke("CentimetersToPoints", 5.5)
O-Matrix will respond

A Method Without Arguments That Returns a Result
Some server methods do not require any data from the client and only perform an operation that returns a result If at the O-Matrix prompt you enter
     fileName = coinvoke("GetSaveAsFileName")
Excel will post a dialog for entering a file name and after pressing OK your input result will be saved to the O-Matrix variable, fileName. If you continue the example by entering
     print fileName
O-Matrix will echo the name of the file that you entered in the dialog.

A Method That Does Not Return a Result
Some methods do not return a result and are used primarily for passing data to a server or for performing operations. The call to coinvoke("Quit") in the example above does not return a result.