LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Labview SubVI to keep previous control values

Solved!
Go to solution

My main VI will pop up a subvi for setting  parameters. So far the subvi works as designed: when the main VI run it, it will pop up, and it will close itself when I finish using it and the data is passed to the main VI.

My question is: while the main VI is running, each time when I use the subVI I have to reenter the control values, Is there a way to let the SubVI to keep the last setting on the controls?

This is essentially same as: open the subVI in first, then run the main VI such that the subVI never close the window. Or same as the SubVI is always run in memory and never close.

I know I can use global variable or let the main VI to keep the settings, but is there any other simpler method?

Thanks!

0 Kudos
Message 1 of 22
(2,884 Views)

We cannot debug descriptions, because you leave out many details. Attach a simplified version of your VI instead.

(How are you "calling" the subVI? Are connectors assigned, etc. etc.)

 

Controls keep their value for the current session (panel open or not) unless you have them assigned to the connector pane. Do you?

If they have assigned connectors, controls are expecting values from the caller, of course.

0 Kudos
Message 2 of 22
(2,865 Views)

Hi,

I have attached the simplified VIs.

Basically the main VI will run the subvi to get a array each time for plot. The SubVI will pop up when called, then I can enter parameters about how to generate the array, then I click "Set" the subVI will return the generated array and exit.

The problem is each time when the SubVI pop up, the controls will reset the value to default, but I want they keep the last values.

I know there are many ways  to achieve this, say global variable, let the main VI to store the subVI setting and pass it each time the SubVI is called. But is there a simpler way?

Guang

Download All
0 Kudos
Message 3 of 22
(2,854 Views)

@gy10c wrote:

Hi,

I have attached the simplified VIs.

 


WARNING!!!!  Don't run those VI's.  I ran the VI and it proceeded to lock up those windows.  I couldn't abort or close any windows.

0 Kudos
Message 4 of 22
(2,845 Views)

One problem is that you used obvious names for the VIs. My downloads folder already contains several "subVI.vi", so the browser named it subVI (4).vi and the main VI will call something completely unrelated, i.e. another random subVI from years ago.

0 Kudos
Message 5 of 22
(2,838 Views)
Solution
Accepted by topic author gy10c

As I said, you need to disconnect these controls from the connector pane. Have you tried?

 

(also, use a shift register instead of a local variable in the subVI)

Message 6 of 22
(2,837 Views)
Solution
Accepted by topic author gy10c

Like this.

"If you weren't supposed to push it, it wouldn't be a button."
Download All
0 Kudos
Message 7 of 22
(2,834 Views)

 

"


@RavensFan wrote:

@gy10c wrote:

Hi,

I have attached the simplified VIs.

 


WARNING!!!!  Don't run those VI's.  I ran the VI and it proceeded to lock up those windows.  I couldn't abort or close any windows.


 

This is not my problem. If you set the VI property to be "show front panel when called" AND your subvi is opened when you run the main vi, it will lock. To unlock, right click the vi icon in the windows taskbar, then close, then labview will close everything and allow you to save.

 

0 Kudos
Message 8 of 22
(2,832 Views)

@altenbach wrote:

As I said, you need to disconnect these controls from the connector pane. Have you tried?

 

(also, use a shift register instead of a local variable in the subVI)


Hi,

Just tried this, Yes! if the controls I want to keep last values is actually not attached to the connector pane, these controls will keep same value as long as the main VI is running.

Thanks!

Guang

0 Kudos
Message 9 of 22
(2,826 Views)

A few more suggestions:

  • Don't use mouse up or down events. Use value changed!
  • Remove the timeout event case if you don't use it.
  • You need an event for the stop buttons.
  • You don't really need the "generate" button, just trigger on any control change.

 

Message 10 of 22
(2,804 Views)