I would like to add a function in a control like the following:
In case that a user of a vi trying to change the value of a control I want a warning to be appeared prompt the user to confirm that he really wants to change the value of the control. What is really important to note is that I want my vi keep running with the control remain at its initial value until the user confirm the change of the value. Only when and if the user confirms the change I want the control value to be updated. Does anyone could make a suggestion?
Thank you in advance
Solved! Go to Solution.
EDIT: Depending how the rest of your code is set up, you will find that the new value could be used before the user accepts it. You could however use one control on the front panel (which is check in the event) and a separate one that is changed and used only if the user accepts the change. Like so:
Thank you for your suggestion. First of all I have to clarify that I was talking about a numeric control, sorry for not specifing earlier. However, correct me if I am wrong or if I haven't realized something but adopting your sugegstion in my case the vi remains stucked until the user makes his selection. For example, connecting the numeric control with a chart, you can see that the chart is not updated after the messages appearance and until the user make his selection.
That is correct. The dialog box that appears is a modal dialog box, and it's a blocking dialog box. If you have something that must continuously update then you need a parallel loop in which you place the code to update the front panel. You could also create your own dialog box and launch it dynamically using the VI server. I think the parallel loop is probably an easier thing to do in your case. There are lots of examples that ship with LabVIEW on parallel loops. You should also spend some time looking at some of the Application Design Patterns.
If you have not already done so, you should spend some time to go through the introduction material, tutorial(s), and other material in the NI Developer Zone's Learning Center which provides links to other materials and other tutorials. You can also take the online courses for free.
Yes - apologies for the poorly thought out dialog example. I was really just using that as an example of a way of checking that the data is correct. It could be replaced with range checks, other user checks etc.
I have implemented similar functions but I prefer to just create my own dialog box out of a sub vi with a couple of buttons. This allows greater control over the appearance but with the same (or more) functionality without blocking other code- e.g.
As for string or numeric controls - it really doesn't matter. Again, I just used strings as an example, but the value change event should still work for your needs (provided you pay attention to smercurio's points about learning about design architectures)