02-11-2009 02:08 PM
Hello,
My front panel has several numeric control that I expect the user to enter data into prior to press a button that takes the values from the numeric controls and
programs a power supply. What I have found out is that if a user types in the numeric control and does not press enter and/or moves the cursor with the mouse to a new
control, the new vales are not captured when the button is pressed.
How do I capture the latest value in the numeric control without expecting the user to press ENTER after they have typed in the desired value?
Solved! Go to Solution.
02-11-2009 02:28 PM
With String Controls, you can use Update Value while Typing. But that property is not available with numeric controls. Nor do I think it should be.
If you are typing in a number a digit at a time, how do you expect LabVIEW to know when you are done typing and that you have established your final value? Otherwise if you were entering a number 1234, it would think 1 is a valid number, then 12, then 123, then finally 1234. I wouldn't want a program executing based on the first 3 numbers if they aren't values that I intended.
02-11-2009 02:32 PM
How are you capturing the numeric values? Are you using an event structure? Make sure that you read the terminals of your numeric controls AFTER you read the button value; if you read them at the same time you'll see the behavior you're describing. For example, say you have a while loop with a case structure inside it, and you wire your button to the case structure so that it will execute when the button is pressed. If you put your numeric controls outside the case structure, at the same level as the button, you may get old data. If you put your controls inside the case structure, you should get the most recent values, because LabVIEW will read the numeric terminals after reading the boolean.
If you need more assistance, post your code.
02-11-2009 02:48 PM
Hello,
I would like to capture the present value of the numeric controls when a button is pressed, which is in a event structure. So how do I get the value of the numeric controls when the button is pressed?
02-11-2009 02:50 PM
Create an event structure. Use 'mouse down' on the enter button as the event (or mouse up....)
Use a property node for each control:
Right click each control, click 'create' >> 'property node'
Select the property 'value'.
Put these property nodes inside the event structure.
Change all to 'read' instead of 'write'.
Then you can use the values.
02-11-2009 02:53 PM
Two possible approaches for capturing the latest value inside an event structure:
1) Read the values of your numeric controls inside the event case for the button. This is the simplest solution. If you need access to those numeric values in other event cases, use the value change event for those controls to update shift registers, or use a local variable.
2) Take advantage of the timeout case (if you're already using it you may have to do some creative reuse). Store the timeout value in a shift register and set it to -1 by default so that it won't execute. In your button event, set that timeout shift register to 0. Move the code from your button event into the timeout case. LabVIEW will re-read the values of your numeric controls and the timeout event will execute immediately.
02-11-2009 03:10 PM
Hello,
Thanks I read the values in the event structure for the button and it works! 🙂