LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Passing Data from a sub

Solved!
Go to solution

I have a simple sub that just has a For loop with the usual index. I want to pass the index to the main vi program and first tried pasing through a wire and connector output to the sub. However, the index does not pass since the loop is busy in the sub. I can use a Global variable but the index just goes to the global variable front panel. How do I get the index numerical value to the front panel of the main vi?

0 Kudos
Message 1 of 11
(3,372 Views)

Do you want pass all the values as from 0 to 500 in array or you what to pass one by one.

0 Kudos
Message 2 of 11
(3,366 Views)

Hi,

 

Did you try using a functional global? Chek out the attached example.


Regards,
NitzZ

(Give Kudos to good Answers, Mark it as a Solution if your problem is Solved;)) 

0 Kudos
Message 3 of 11
(3,356 Views)
Solution
Accepted by tomnz

Create a reference to your Index in your main.vi and pass this to the SubVI. In your SubVI write your index value to the Property Value.

 

passing reference.png

 

Dont forget to include the reference on you connector pane

Regards
Ray Farmer
Message 4 of 11
(3,349 Views)

Hi,

 

You can also try this approach using the control refernce. Though i would suggest the Functional globals.


Regards,
Nitzz

(Give Kudos to good Answers, Mark it as a Solution if your problem is Solved:smileywink:)  

0 Kudos
Message 5 of 11
(3,346 Views)

example

 

Regards
Ray Farmer
0 Kudos
Message 6 of 11
(3,332 Views)

Thanks but I am a bit confused as to what to put in the main prog. I have this (attached) but it doesn't work.

0 Kudos
Message 7 of 11
(3,315 Views)

Ok I got it now. Great solution - simple.

Message 8 of 11
(3,309 Views)

Fascinating but too complex

0 Kudos
Message 9 of 11
(3,299 Views)

only problem is when you press the stop button, you have to wait until the 500 iteration of the For loop has complete which is why I changed the subvi to a while loop so that the button is passed down too the subvi to stop the while loop as well.

 

 

Regards
Ray Farmer
0 Kudos
Message 10 of 11
(3,284 Views)