LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Who is memory allocated to a controll in a reentrant VI?

Hi,

I want to have a variable number of string controls with references pointing on them. First I tried to use a reentrant VI consisting of a string control and as output the reference to this control. But then LabVIEW gives me always the same reference, which after some thought I realized is logical, since the same instance of the reentrant VI is called.

Therefore I tried to load dynamically the reentrant VI, saving the references of the strings and the loaded VIs in an array to "deallocate" the memory later, when I do not need them anymore. But this did not work, too, which I do not understand, since now new memory for every loaded instance of the VI should be allocated.

I placed my test VIs in a z
ip for you. There are some German words, but this should not be a problem for understanding the VIs.

So does anyone have an idea how to "allocate" a variable number of string references?

Thanks for your help in advance.
Marc
0 Kudos
Message 1 of 3
(2,707 Views)
Hi Marc,

Please correct me if I'm wrong. I think reentrant VIs duplicates the data space, but not the front panel controls (that's why you cannot highlight execution for reentrant VIs). In your "Dynamische String Referenz.vi", each dynamically opened reentrant VI has its own refnum, but the ctrlrefnum to the "String" control stays the same.

I modified two of your VIs a bit to do what your program tries to do. Instead of passing String's control refnum, you can pass VI refnum to each instance instead, and grab the value of the control by invoke nodes. You should use the same "String Referenz.vi" in your original zip file.

Hope this helps,
Dan
0 Kudos
Message 2 of 3
(2,707 Views)
Hi Dan,



I realized this on Friday on my way home. I remembered from a probe on a ctrlrefnum, that it is defined by its owner, which is always the same VI, reentrant or not. Which is very interesting for setting values of reentrant VI's dynamically (I never had to do this, but you never know...).

Your solution came to my mind as well on my way home. I should always drive with my bike, when I'm thinking about problems. Seems to help;-)

Anyway, Dan, thanks for help!

Bye, Marc
0 Kudos
Message 3 of 3
(2,707 Views)