LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Control references

I'm in the process of cobbling together a VI that takes a VI name and a
control name and returns a reference to that control, in LV6. Firstly, I've
not dug deeply through the LV6 directory so am I duplicating an existing
function?

Secondly, I'm tackling the problem by opening a reference to the named VI,
getting a reference to the front panel and then getting an array of
references to the controls on the front panel from the relevant property of
the "panel" object. I then go through the array of controls checking the
"Label.Text" property to find the one I want. However, am I right in
thinking that I have to make sure I close all of the other unwanted
references in this array behind me? If so, I could be opening many tens of
references
for a complex panel and having to cycle through them all closing
them again. This seems inelegant and inefficient- is there a better way?
0 Kudos
Message 1 of 3
(2,622 Views)
Craig Graham wrote:
>
> I'm in the process of cobbling together a VI that takes a VI name and a
> control name and returns a reference to that control, in LV6. Firstly, I've
> not dug deeply through the LV6 directory so am I duplicating an existing
> function?
>
> Secondly, I'm tackling the problem by opening a reference to the named VI,
> getting a reference to the front panel and then getting an array of
> references to the controls on the front panel from the relevant property of
> the "panel" object. I then go through the array of controls checking the
> "Label.Text" property to find the one I want. However, am I right in
> thinking that I have to make sure I close all of the other unwanted
> references in this array behind me? If so, I could be opening m
any tens of
> references for a complex panel and having to cycle through them all closing
> them again. This seems inelegant and inefficient- is there a better way?

Hm, I didn't have this problem. Did you tried to get references from
another vi, or from the same one?
If not, try to open reference from another vi. In manuals they say that
there is no need to close references, but you can. I've tried both ways
and all works, but from separate vi.

It seems that opening reference from the diagram to front panel of the
same vi causes troubles some times.
There is references tree drawing in online help. Very useful to
understand FP classes structure.

May be this will help a little,

Regards,
--
Sergey Krasnishov
____________________________________
Automated Control Systems
National Instruments Alliance Member
Moscow, Russia
sergey_acs@levsha.ru
http://acs.levsha.ru
0 Kudos
Message 2 of 3
(2,622 Views)
Sergey Krasnishov wrote in message
news:3A019259.4B91F553@levsha.ru...

> Hm, I didn't have this problem. Did you tried to get references from
> another vi, or from the same one?
> If not, try to open reference from another vi. In manuals they say that
> there is no need to close references, but you can. I've tried both ways
> and all works, but from separate vi.
>
> It seems that opening reference from the diagram to front panel of the
> same vi causes troubles some times.
> There is references tree drawing in online help. Very useful to
> understand FP classes structure.
>
> May be this will help a little,

This is to get a reference from another VI in order to change captions and
values of controls from outside a given VI.

I don't
know what it says about not closing references, but I'm not so sure
I believe it in general 🙂 Labview will close all open references when the
last running VI stops executing, but if you have VIs running long term and
you don't close references behind you, eventually you simply can't open any
more references and attempts to do so fail with an "out of memory" error
(even though there's plenty of available RAM). This is certainly the case in
Labview5 because I've suffered greatly from it in the past, so I'd be
interested to know if there's now some intelligent cleanups done as an
individual VI exits, though exactly how such a thing would work I don't
know.

I have to clarify that I'm not having problems as such- the VI runs and I'm
now using it. It's simply that it seems inelegant to have to open a
reference to all the front panel controls as a big array of the things and
then have to go through and close them all. If you want to load a text file
you don't have to load all the files in a
directory and scrap the ones you
don't need. Unless you have an "interesting" programming style of course 🙂
0 Kudos
Message 3 of 3
(2,622 Views)