09-07-2020 04:38 PM
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 :
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.
Solved! Go to Solution.
09-07-2020 05:34 PM
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.
09-07-2020 05:47 PM
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.
09-07-2020 05:57 PM
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?
09-07-2020 06:23 PM
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.
09-07-2020 09:30 PM
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.
-Kevin P
-Kevin P
09-07-2020 10:21 PM
thanks, it does simplify the design.
09-08-2020 01:11 AM
If you have many Controls you only need to have them in a cluster and it's only 1 wire regardless. 🙂