From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Change values of control using subvia

Solved!
Go to solution

What I would like to achieve is changing value of a variable using SubVia. I had this problem since the beginning of using LabVIEW and always get around it by using local variable of control but I have never found or seen a good solution to it.

 

Assume a variable enters a SubVia and the user can see value of the available and is able to change it or discard the changes.

 

My solution always been something similar to the following block diagram :

ChangeVia.jpg

 

 

this works but this become complex when there is more variable to change. I reckon there is a better solution to this but I could not find it.

Really appreciate your help and sorry for my profound ignorance.

 

0 Kudos
Message 1 of 8
(3,119 Views)

It is not completely clear to me what you are trying to do.

 

How is it more complicated if you have more controls?

 

If you want to change a control on the main VI from within a subVI, you can pass in a reference to the control into the subVI and attach that to a Value Property node explicitly to change the value on the main VI.

0 Kudos
Message 2 of 8
(3,095 Views)

It is not necessary a control on main via it can be a value in a shift register.

 

Assume, the user wants to change a temperature threshold, when the user clicks a button a SubVia (similar to attached one) pops up in which the user can see the current value, change value and set it or after change decide to discard the change and cancel it.

 

As you can see in the SubVia for changing one value, one control as an input, one indicator as output, one control for changing variable plus a local variable to input control to show the current value to the user. e.g if user wants to change two variables, using this approach, 4 controls and two indicators and two local variable will be needed .  I was wondering if there is a better solution to this.

0 Kudos
Message 3 of 8
(3,091 Views)

First.  It is VI and SubVI.  There is no "a" in either of them.

 

So you want a subVI that acts as a dialog that lets you confirm whether you want to change 1 value or 2?  Are they always doubles, or ever a different datatype?  Ever more than 2 values?

 

If it is only 2, I'd just create two different subVI's.  If it is any random number of variables at once, you could create one VI and have it show or hide the number of controls that is needed.

 

I doubt you would need such a wide range of different dialogs.  If so, I'd consider changing the architecture.

 

Do you really need a pop up dialog?

0 Kudos
Message 4 of 8
(3,082 Views)

the architecture is based on queued massage handler template. The whole application has some set values for different settings however sometimes the user need to change some of them (using run time menu in my case).

 

My question is not really architecture based, for example the attached dialog at some points shows current values to user and user either changes it i.e click Set or decide to discard the changes and go with previous values i.e click Cancel.

 

The input control and output indicator can be anything (serial port number, string, double ...)

 

As mentioned  the suggested SubVia works fine but I don't think it is an optimal solution, I am looking for best practice in this sort of situation.

 

 

0 Kudos
Message 5 of 8
(3,076 Views)
Solution
Accepted by topic author Dr--X

Well, this is only barely any different, but you don't seem to need the "Change" control at all.  See snippet below, "Cancel" event passes In to Out, like before.

 

ChangeVariableSubVia_BD.png

 

-Kevin P

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
Message 6 of 8
(3,060 Views)

thanks, it does simplify the design.

0 Kudos
Message 7 of 8
(3,048 Views)

If you have many Controls you only need to have them in a cluster and it's only 1 wire regardless. 🙂

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 8 of 8
(3,036 Views)