Hello all,
I've got an OCX/ActiveX object which has a method which is, in the IDL file, described as follows :
HRESULT SetData([in] float val1,[in] float val2,[in] float val3);
I just tried to write a method to retrieve that data again, and its descriptione looks like this :
HRESULT GetData([in] float* val1,[in] float* val2,[in] float* val3);
When I try to call the methods from within VBScript like this :
call oData.SetData(1,2,3)
call oData.GetData(v1,v2,v3)
-or-
oData.GetData v1,v2,v3
the "SetData" one works, but for some reason the "GetData" ones (both) generate an "type mismatch" error (and the methods code in the OCX doesn't get called).
My question : what should the "GetData" description in the IDL look like ?
Remark :
I got the "GetData" method to work by changing the "float*" to "variant*" (and change the called method accordingly), but would like to have both methods and arguments to be copies of each other - just working in opposite directions.
HRESULT GetData([in] float* val1,[in] float* val2,[in] float* val3);
On Wed, 16 Aug 2023 13:22:54 +0200, R.Wieser wrote:
HRESULT GetData([in] float* val1,[in] float* val2,[in] float* val3);
That should be defined as:
HRESULT GetData([in, out] float* val1,[in, out] float* val2,[in, out] float* val3);
Otherwise, the function will get the pointer to the copy of the given
values. Because VBScript can not specifically pass a function argument by reference. e.g. this will cause a syntax error:
retVal = obj.GetData(byref v1, byref v2, byref v3)
In VBScript, the use of `byref` operator outside of a subroutine/function declaration, is not available. It's only available in VB/VBA.
I don't know VBScript at all,
In C .... you would need to change it to oData.GetData(&v1,&v2,&v3) to
tell it to pass
in addresses.
The raw SetData and GetData functions are not quite quite "copies of each other"
That should be defined as:
HRESULT GetData([in, out] float* val1,[in, out] float* val2,[in, out]
float* val3);
Otherwise, the function will get the pointer to the copy of the
given values.
IDL example for a method which uses its multiple arguments as output is
the IWebBrowserApp::ClientToWindow, which is defined in SHDOCVW.DLL's
type library.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 379 |
Nodes: | 16 (2 / 14) |
Uptime: | 42:02:15 |
Calls: | 8,141 |
Calls today: | 4 |
Files: | 13,085 |
Messages: | 5,857,792 |