LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

ActiveX Variant Pointer -> Variant?

Hello.
I have an ActiveX control that requires a VARIANT to be passed in. The VARIANT needs to contain a SAFEARRAY of int32s. I have a DLL that assembles the variant SAFEARRAY from a standard LabVIEW array. However, because of limitations on Call Library Function Nodes my DLL function has arguments of long * and VARIANT *. So I end up with a VARIANT pointer rather than a plain VARIANT.
Q. Why can't Call Library Function Nodes just return a VARIANT?
Moving along, I wire the VARIANT pointer to a "To Variant" vi and then wire the output to my ActiveX control method.
=> The ActiveX control (IDL SetNamedArray) is meant to share memory with the container application. I assume this is possible by sharing the SAFEARRAY pointed to by p
array within the VARIANT. The problem is that this doesn't work. The error returned is that "memory is locked" in the vi.
Q. Does LabVIEW lock SAFEARRAYs?

If anyone has had any experience manipulating SAFEARRAY VARIANTs in LabVIEW and passing them to ActiveX controls I'd be most interested to hear of any tricks and undocumented features.

cheers,
Novak.
0 Kudos
Message 1 of 6
(3,892 Views)
> I have an ActiveX control that requires a VARIANT to be passed in.
> The VARIANT needs to contain a SAFEARRAY of int32s. I have a DLL that
> assembles the variant SAFEARRAY from a standard LabVIEW array.


You should be able to just wire the LV array of int32s to the OLE method
parameter. LV knows what type the OCX requires, and it knows its type.
You do not have to build the variant yourself.

Greg McKaskle
0 Kudos
Message 2 of 6
(3,892 Views)
Just one more followup, Once you have the ActiveX method selected, it
automatically shows the parameter names. You can also popup on these
and create a control, indicator, or constant. Creating a control is a
good way to find the LV type that you should build to send to a method.

Greg McKaskle
0 Kudos
Message 3 of 6
(3,892 Views)
But I need to do something different because wiring an LV array straight into the method will copy the data into the IDL ActiveX control but the memory is not shared between LV and IDL - I get the memory locking error and the method fails (returns 0). Thats why I tried making the VARIANT myself. I've contacted IDL and when I resolve this issure I will post my findings because it might be of general interest amongst users of ActiveX controls in LV.

Novak.
0 Kudos
Message 4 of 6
(3,892 Views)
> But I need to do something different because wiring an LV array
> straight into the method will copy the data into the IDL ActiveX
> control but the memory is not shared between LV and IDL - I get the
> memory locking error and the method fails (returns 0). Thats why I
> tried making the VARIANT myself. I've contacted IDL and when I
> resolve this issure I will post my findings because it might be of
> general interest amongst users of ActiveX controls in LV.
>

If you want there to be shared memory between the two, then you should
probably look to make additional methods, one that allocates if
necessary and copies the LV data into the shared space, and another to
return the value to the LV diagram from the shared memory.

Greg McKaskl
e
0 Kudos
Message 5 of 6
(3,892 Views)
This discussion is EXTREMELY SIMILAR to a problem I am currently facing. Was a solution ever discovered to this?

~Tim
0 Kudos
Message 6 of 6
(3,892 Views)