LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

update while typing in numeric control?

So...
When I type a number into a numeric control, it doesn't update until I hit enter or click somewhere outside the control.
Problem is, after entering the number, I want to click on a "go" button to do something with the new value in numeric control, but unless I remember to click somewhere else or hit enter first, I'm doing something with the old value, not the new value.
This gets aggravating.

How to make sure the value of the numeric control gets updated before doing something with it?
"update while typing" exists for string controls, but seems conspicuously lacking for other types of controls...





0 Kudos
Message 1 of 10
(6,139 Views)
Clicking on the GO button will update the new value in the numeric control. You don't need to click elsewhere first after typing the number.
 
Try it! 🙂
 
(If it still does not work, your code has a problem. Please attach your VI. One possible problem is with for example event structures if the numeric control feeds into the event structure from the left and the go button triggers the event. Use execution highlighting to see the dataflow and troubleshoot).

Message Edited by altenbach on 03-21-2006 02:29 PM

0 Kudos
Message 2 of 10
(6,123 Views)

If you are using a version with the event structure (7.x +) you can make an event for your "go" button and have the numeric control with in that. What ever is in the control at the time of your "go" event, will be read.

 

 

Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



0 Kudos
Message 3 of 10
(6,120 Views)
Thanks for the answers.

However...
I'm using LabVIEW 8.0
I'm using an event case to handle my "go" button.
Inside the event case, I am using the value of the numeric control.

Yes, the value in the numeric control gets updated when I click the "go" button, but not before the event case executes, it seems.

0 Kudos
Message 4 of 10
(6,111 Views)
Hi Mesa:

May be, your numeric control is not in the right position.

May be your control's value is processed before the go event is catched.

Are you using the control inside the event, or you are using a local variable, or a wire from outside the event structure?
Aitortxo.
0 Kudos
Message 5 of 10
(6,107 Views)
OK, so from reading (and re-reading) some of these replies, I need to place my control inside the event loop, and not use a local variable.
I've attached a picture of my event case. It looks like I'm using a local variable. So I will have to change that.

My next question is...
What if I need to get the value of the numeric control in more than one event case?
0 Kudos
Message 6 of 10
(6,104 Views)
Hi Mesa:

Sorry, for mentioning local variables, as they can be used for your purpose.

So, it seems you resolved your problem, don't you?
Aitortxo.
0 Kudos
Message 7 of 10
(6,093 Views)
Nope. Still not resolved.

I've tried it both ways.
1) Putting the numeric control inside the event case,
2) putting a local variable linked to the numeric control inside the event case.

In both cases, the event case executes before the value of the numeric control gets updated.

Maybe I need to bring in the value of the control from outside the event case via a wire?

I'll try it.

As you can tell, I don't know what I'm doing....
0 Kudos
Message 8 of 10
(6,084 Views)
OK,

I fixed it by adding a 10 ms wait in the event case before doing anything with the value of the numeric control.


0 Kudos
Message 9 of 10
(6,081 Views)
I cannot reproduce your described behavior: With either a local variable or the numeric control inside the event case, I never see a stale value. Please attach your VI so we can troubleshoot.
 
Adding a delay to fix something like this is incorrect and dangerous. If a delay solves the problem, it points to a flaw in the code.  What if somebody will run your program on a slower computer where it would suddenly need a 12ms delay. You'd be back to sqaure one, dealing with race conditions. 😞
 
(And why are you using "mouse down" instead of "value changed"?)
 

Message Edited by altenbach on 03-21-2006 05:22 PM

Message 10 of 10
(6,073 Views)