Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat's the Matlab equivalent of NULL, when it's calling COM/ActiveX methods?
    text
    copied!<p>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 <b>Matlab's ActiveX support</b> and are having trouble <b>calling COM object methods with a NULL parameter</b>.</p> <p>They've asked how they do this in Matlab - and I've been scouring <a href="http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_external/bq4epvg-1.html" rel="noreferrer">Mathworks' COM/ActiveX documentation</a> for a day or so now and can't figure it out.</p> <p>Their example code might look something like this:</p> <pre><code>function do_something() OurAppInstance = actxserver('Foo.Application'); OurAppInstance.Method('Hello', NULL) end </code></pre> <p>where <code>NULL</code> is where in another language, we'd write <code>NULL</code> or <code>nil</code> or <code>Nothing</code>, or, of course, pass in an object. The problem is this is optional (and these are implemented as optional parameters in most, but <i>not all</i>, cases) - these methods expect to get NULL quite often.</p> <p>They tell me they've tried <code>[]</code> (which from my reading seemed the most likely) as well as <code>''</code>, <code>Nothing</code>, <code>'Nothing'</code>, <code>None</code>, <code>Null</code>, and <code>0</code>. I have no idea how many of those are even valid Matlab keywords - certainly none work in this case.</p> <p>Can anyone help? What's Matlab's syntax for a null pointer / object for use as a COM method parameter?</p> <p><strong>Update:</strong> Thanks for all the replies so far! Unfortunately, none of the answers seem to work, not even <code>libpointer</code>. The error is the same in all cases:</p> <p><code>Error: Type mismatch, argument 2</code></p> <p>This parameter in the COM type library is described in RIDL as:</p> <pre><code> HRESULT _stdcall OurMethod([in] BSTR strParamOne, [in, optional] OurCoClass* oParamTwo, [out, retval] VARIANT_BOOL* bResult); </code></pre> <p>The coclass in question implements a single interface descending from IDispatch.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload