What's the Matlab equivalent of NULL, when it's calling COM/ActiveX methods?

Posted by David M on Stack Overflow See other posts from Stack Overflow or by David M
Published on 2010-02-17T04:45:26Z Indexed on 2010/04/28 2:53 UTC
Read the original article Hit count: 319

Filed under:
|
|
|
|

Hi,

I maintain a program which can be automated via COM. Generally customers use VBS to do their scripting, but we have a couple of customers who use Matlab's ActiveX support and are having trouble calling COM object methods with a NULL parameter.

They've asked how they do this in Matlab - and I've been scouring Mathworks' COM/ActiveX documentation for a day or so now and can't figure it out.

Their example code might look something like this:

function do_something()
   OurAppInstance = actxserver('Foo.Application');
   OurAppInstance.Method('Hello', NULL)
end

where NULL is where in another language, we'd write NULL or nil or Nothing, or, of course, pass in an object. The problem is this is optional (and these are implemented as optional parameters in most, but not all, cases) - these methods expect to get NULL quite often.

They tell me they've tried [] (which from my reading seemed the most likely) as well as '', Nothing, 'Nothing', None, Null, and 0. I have no idea how many of those are even valid Matlab keywords - certainly none work in this case.

Can anyone help? What's Matlab's syntax for a null pointer / object for use as a COM method parameter?

Update: Thanks for all the replies so far! Unfortunately, none of the answers seem to work, not even libpointer. The error is the same in all cases:

Error: Type mismatch, argument 2

This parameter in the COM type library is described in RIDL as:

    HRESULT _stdcall OurMethod([in] BSTR strParamOne, [in, optional] OurCoClass* oParamTwo, [out, retval] VARIANT_BOOL* bResult);

The coclass in question implements a single interface descending from IDispatch.

© Stack Overflow or respective owner

Related posts about matlab

Related posts about com