LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Passing array to ActiveX object method

I need to pass the array by pointer as a parameter into method of an ActiveX object. More detailed - to ActiveX/COM object which represents the arbitrary waveform generator hardware.
How it is possible to do in LabView?
Thank you!
0 Kudos
Message 1 of 9
(4,393 Views)
Baturin,
The ActiveX object documentation should tell you what this input type is, array or variant. The activex designer probably didn't request how to pass this data, by value or reference.
LabVIEW activeX interface doesn't support passing data by pointers.
When you drop this method in LabVIEW, LabVIEW will either recognize that the input is an array, or if it cannot recognize the type, it will leave it as variant. If you can create array input, then wire an array. If it is a variant, convert your array with "To Variant" function.
Zvezdana S.
0 Kudos
Message 2 of 9
(4,393 Views)
There is declaration of COM method I need to use:
[id(15), helpstring("method SetData")]
HRESULT SetData([in] DOUBLE* newVal, [in] ULONG length, [in] USHORT MBIndex, VARIANT_BOOL bUpdate).

The main important psrsmeters is newVal and length.
Unfortunately I can not wire an array to NewVal.
There is a screenshot from LabView in the attachement...
0 Kudos
Message 3 of 9
(4,393 Views)
Beturin,
From the snapshot and the function declaration, the newVal input is not an array, but it is pointer to double. You cannot wire array to that method. If you right click on the newVal input and select to create a constant, it will create a double constant.
Zvezdana S.
0 Kudos
Message 4 of 9
(4,393 Views)
Yes, it is the pointer to double, ... From LabView point of view newVal really is not an arry because LabView doesn't know about size, but we need it to be an array 😞 Is this the main problem?
What should be the correct declaration of this method in this case?

I have only a little experience with COM 🙂 So it is not so trivial for me...

Thank You very much for your help!
0 Kudos
Message 5 of 9
(4,393 Views)
Since the NewVal input is declared as pointer to double, and LabVIEW recognized this input on the invoke node as double, you can only wire a double and not an array. I assume the length input will be the size you are looking for.
The COM object expects it to be double, and you cannot change the parameter type from within LabVIEW.
Zvezdana S.
0 Kudos
Message 6 of 9
(4,393 Views)
Thank you very much!
Yes, I realize it.
Is it possible to change the method declaration in COM object to pass an array in LabView? I can contact with developer of this COM object and He ready to change the interface...
0 Kudos
Message 7 of 9
(4,393 Views)
If the COM developer changes the declaration of this parameter to be array, or pointer to array, and then gives you this updated object, LabVIEW will recognize the newVal input as an array. When you right click on input to the invoke node in LabVIEW, and select to create a constant, it will automatically create the correct type constant. Or, you can just wire an array output of another VI to an array input on the invoke node.
Zvezdana S.
0 Kudos
Message 8 of 9
(4,393 Views)
Have you an idea about required steps to create the COM method with an array as parameter? (VisualC++ 6.0)
Unfortunately we don't know how to do it :((

We have tested several types of parameter declaration but failed... May be there are some examples in VC6 about it?

Thank you for any help!
0 Kudos
Message 9 of 9
(4,393 Views)