LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

recall the Sub VI

Hi all,

I have 2 VIs which are named "Main" and "Sub". In the "Main" VI, there is a boolean button to open the "Sub" VI. When i press it, "Sub" VI opens. In the "Sub" VI, there is another boolean button to return the "Main" VI. They work well. But when i press "Open Sub VI" button for second time, it does not work.

Anyone have any ideas of how can i can fix this problem?

I have attached the VIs.

 

Best Regards!

Thanks!
~drycsr~
Download All
0 Kudos
Message 1 of 2
(2,430 Views)

Run your main VI in highlight mode and you will see the problem. When you click on the "Main VI" button on the subVI's front panel you are closing its panel, but the subVI is still running. Hence, the main VI is still waiting for the subVI to finish so that it can get the data it depends on. Dataflow programming, not sequential-based programming, which is what you seem to be doing. Thus, you need to stop the subVI's loop on whether the user presses the Stop button or the "Main VI" button.

 

Code comments:

  • In the subVI your event structure is not being used properly. You have a value change event case for the "Main VI" button. So, place the code that you have in the loop inside that event case. Also create a value change event for the Stop button. You can wire out a True/False out of both of these to control the while loop.
  • What exactly are you doing in the main VI? You are taking the value of the Combo box and then writing that to a string, and then using a local variable (note that the way you have it right now you have a race condition) for the true string of the Match True/False String. WHY?
  • You do not need to wire a constant value to sequential inputs of the Index Array. When expanded the value is automatically incremented. 
  • You already have the subVI set up to open its front panel when called. You should not set it up to open its front panel when loaded. The code you have in your main VI that's intended to execute after the subVI is irrelevant.
Message 2 of 2
(2,419 Views)