LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

string control unable to update context at runtime!

Solved!
Go to solution

Hi,

I put a string control in my front panel. but I found the text I typed in unable to transfer to my program at real time. for example, I type 5 in the string box and push a button to transfer the character to some where. next time I type 6 in this control again and push buttong again. however, this time the control still trasfer 5 to my program. To solve the bug, I have to mark "Update value while typing" from control property. Why? the control don't update its value automatically?

0 Kudos
Message 1 of 6
(2,764 Views)

Everything about this, other than being solved by using "update value while typing", suggests a dataflow issue.  For instance, having the control outside of a loop and trying to read its (changed) value insde the loop.

 

Please post your code and any steps needed to recreate the issue.

0 Kudos
Message 2 of 6
(2,750 Views)

Hi Z,

Here is VI. I use this VI to input data to a database. I put some string control in front panel and use an Event struct. When user click "Ok" button, the data from controls should be fetched and inject into a cluster. But sometimes, the value from control is the character I typed las time.

 

0 Kudos
Message 3 of 6
(2,732 Views)
Solution
Accepted by topic author song403

Ah. Ok.  I've had this happen to me a few other times and I believe what is going on is that the OK button mouse down event is firing before the string is updating after losing focus.  I've fixed this in the past by forcing a focus change to any other control before trying to read the string (in this case).  Here, I changed your code to be "OK value change" and I added a blank case for "OK mouse down".  I believe the order the events are processed is mouse down?, mouse down, and then value change so by having the case before your write to DB executes it gives the string time/reason to update. 

 

This feels cludgy and probably wrong, but it works.  Hopefully someone will be along shortly to provide a better way.

 

 

In the process of looking into this I took the liberty of condensing your block diagram.  I also created a version that didn't try to write to DB or automatically exit.  I attached both versions.

0 Kudos
Message 4 of 6
(2,725 Views)

This thread describes a similar issue:

The return key should register a value change event on the active and edited control, before togglin...


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 6
(2,695 Views)

Hi,

Thanks so much. Your solution is fine. I also explore the thread listed in above response. It seems this bug was fixed in Labview 2014. Share this information for you all.

0 Kudos
Message 6 of 6
(2,674 Views)