LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I store ActiveX refnums and pass them across VI's?

I am putting together an application that needs to keep track of handles to ActiveX objects (refnums). I am trying to store the refnums in an array of variants in a global variable. The reason for the global is that the program creates an instance of an ActiveX object when it starts, and needs to use that refnum when the program finishes. The problem is that the refnum appears to be invalid when I retrieve it from the global variant array. I use the same ActiveX reference to convert the variant data to a refnum that I did to create the refnum to begin with. When I look at the properties and methods associated with the restored refnum, they are all there as expected. The actual value of the refnum is the same as
when it was created(a 32 bit value). I can perform these same steps within a single vi (convert to variant, restore, and use), but it fails when I pass the data to the global. I perform these same steps in TestStand successfully (storing the refnum in a TestStand variable.)

LabVIEW help says that a refnum is a valid data type. I cannot figure out a way to isolate the problem any further. How do I get a good refnum back from my global array?
0 Kudos
Message 1 of 6
(3,372 Views)
I have tried to do something similiar except that I choose to store my
refnums in a cluster which is kept in memory as a LV2 style shift register
global. This works quite well, but you must be careful that the vi that
made the automation open call remains part of a running hierarchy since LV
will try to "do you a favor" by closing automation references when the vi
that created them stops running.

Mike Sachs
Intelligent Systems

"lars" wrote in message
news:5065000000080000004F690000-1031838699000@exchange.ni.com...
> I am putting together an application that needs to keep track of
> handles to ActiveX objects (refnums). I am trying to store the refnums
> in an array of variants in a global variable. The reason for the
> global is that the program c
reates an instance of an ActiveX object
> when it starts, and needs to use that refnum when the program
> finishes. The problem is that the refnum appears to be invalid when I
> retrieve it from the global variant array. I use the same ActiveX
> reference to convert the variant data to a refnum that I did to create
> the refnum to begin with. When I look at the properties and methods
> associated with the restored refnum, they are all there as expected.
> The actual value of the refnum is the same as when it was created(a 32
> bit value). I can perform these same steps within a single vi (convert
> to variant, restore, and use), but it fails when I pass the data to
> the global. I perform these same steps in TestStand successfully
> (storing the refnum in a TestStand variable.)
>
> LabVIEW help says that a refnum is a valid data type. I cannot figure
> out a way to isolate the problem any further. How do I get a good
> refnum back from my global array?
Message 2 of 6
(3,372 Views)
Hi,

It's been a while since I last used TestStand (it was the test version), but
if I recall correctlly, the VI's are released from memory after calling.

This means: all globals are removed and all activeX objects are closed. Just
a thought, I have no way of testing this...

You must find a way to keep the reference in memory, maybe by dynamically
starting a Vi that opens the reference, and puts is in the buffer. This Vi
should keep on looping.

Btw: instead of a global variant array, you might use a I32 array, and cast
the references to I32 and back. Variants are memory consuming, and slow.




"lars" wrote in message
news:5065000000080000004F690000-1031838699000@exchange.ni.com...
> I am putting together an application that needs to keep track of

> handles to ActiveX objects (refnums). I am trying to store the refnums
> in an array of variants in a global variable. The reason for the
> global is that the program creates an instance of an ActiveX object
> when it starts, and needs to use that refnum when the program
> finishes. The problem is that the refnum appears to be invalid when I
> retrieve it from the global variant array. I use the same ActiveX
> reference to convert the variant data to a refnum that I did to create
> the refnum to begin with. When I look at the properties and methods
> associated with the restored refnum, they are all there as expected.
> The actual value of the refnum is the same as when it was created(a 32
> bit value). I can perform these same steps within a single vi (convert
> to variant, restore, and use), but it fails when I pass the data to
> the global. I perform these same steps in TestStand successfully
> (storing the refnum in a TestStand variable.)
>
> LabVIEW help says that a refnum is a
valid data type. I cannot figure
> out a way to isolate the problem any further. How do I get a good
> refnum back from my global array?
0 Kudos
Message 3 of 6
(3,372 Views)
Btw,

Regards,

Wiebe.

"Wiebe@AIR" wrote in message
news:3dedd071$0$2234$e4fe514c@dreader6.news.xs4all.nl...
> Hi,
>
> It's been a while since I last used TestStand (it was the test version),
but
> if I recall correctlly, the VI's are released from memory after calling.
>
> This means: all globals are removed and all activeX objects are closed.
Just
> a thought, I have no way of testing this...
>
> You must find a way to keep the reference in memory, maybe by dynamically
> starting a Vi that opens the reference, and puts is in the buffer. This Vi
> should keep on looping.
>
> Btw: instead of a global variant array, you might use a I32 array, and
cast
> the references to I32 and back. Variants are memory consuming, and slow.
>
>
>
>
> "lars" wrote in message
> news:5065000000080000004F690000-1031838699000@exchange.ni.com...
> > I am putting together an application that needs to keep track of
> > handles to ActiveX objects (refnums). I am trying to store the refnums
> > in an array of variants in a global variable. The reason for the
> > global is that the program creates an instance of an ActiveX object
> > when it starts, and needs to use that refnum when the program
> > finishes. The problem is that the refnum appears to be invalid when I
> > retrieve it from the global variant array. I use the same ActiveX
> > reference to convert the variant data to a refnum that I did to create
> > the refnum to begin with. When I look at the properties and methods
> > associated with the restored refnum, they are all there as expected.
> > The actual value of the refnum is the same as when it was created(a 32
> > bit value). I can perform these same steps within a single vi (convert
> > to variant, restore, and use), but it fails when I pass the data to
> > the global. I perform these same steps in TestStand successfully
> > (storing the refnum in a TestStand variable.)
> >
> > LabVIEW help says that a refnum is a valid data type. I cannot figure
> > out a way to isolate the problem any further. How do I get a good
> > refnum back from my global array?
>
>
0 Kudos
Message 4 of 6
(3,372 Views)
This is exactly what the problem turned out to be. As long as there is an active execution, the refnums remain valid. More specifically, I think the thread stays active which means the refnum actually means something.

Thanks!
Larry
0 Kudos
Message 5 of 6
(3,374 Views)

There may be more recent discussions about this, but I couldn't find any.  I am having a similar problem, where I store TestStand ActiveX references to a Sequence context in an uninitialized shift register.  In my case, the references are passed into the VI from TestStand (not created from within the VI).  In addition, if I call the VI same VI in the very next step (same sequence and execution as the previous step), the ActiveX references from the shift register are invalid.

 

The VI remains reserved to run over the course of both steps and is not unloaded from memory, so the shift register data should remain intact (in fact, the numeric values of the references are in fact preserved).  Does LabVIEW still attempt to close any ActiveX references even if they weren't created from within the VI?  Is there a way around this issue?  Or am I just doing something wrong?

 

Message Edited by jsiegel on 01-13-2009 11:42 AM
Message Edited by jsiegel on 01-13-2009 11:45 AM
0 Kudos
Message 6 of 6
(2,881 Views)