LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

string control value change event not triggering

Solved!
Go to solution

hi,

i am trying to scan a barcode with a usb HID barcode scanner. i am using an event structure to detect the value change of a string control. when i scan the barcode, the string control updates on the front panel but the event does not trigger until i left click my mouse on the front panel. can any one help? see vi attached

Download All
0 Kudos
Message 1 of 15
(8,835 Views)

I can't look at your code right now (no LV 12 handy), but you should know that the VALUE CHANGED event happens in two and only two circumstances:

1... The USER changes the value from the front panel, by typing or Inc/Dec, or paste.

2... Somebody feeds a value to the VALUE(SIGNALING) property node.  In this case, the event will fire whether the value actually changes or not.

 

The event will NOT happen if:

A... You set a LOCAL VARIABLE

B... It's an indicator and you set a value via the TERMINAL.

C... You set a value via a VALUE property node.

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 2 of 15
(8,828 Views)

hi CoastalMaineBird thanks for the reply......

i am trying to trigger a "VALUE CHANGE" event of the control labeled "String" (see jpeg).

the barcode scanner is a HID device and my PC sees it as a keyboard.

so i woiuld have thought this would be consistant with the first point of your post.

also on a side note, when i type a string from the keyboard the event only triggers when i press enter. this is ok for entering a barcode from the keyboard, but can be annoying when trying to scan the barcode in.

0 Kudos
Message 3 of 15
(8,821 Views)

This is because the string control doesn't trigger the value changed event until the control loses focus. The reason for this is there's, no way for the control itself to know when the value has actually changed to the final value that the user actually wants. For this case, however, there is an option on the string control to "update value while typing." If you select that, you should get the functionality you want. 

Message 4 of 15
(8,820 Views)

i did try that..... the only problem is that the event will be triggered for every character of the barcode i.e. if i have a 10 character barcode the event will be triggered 10 times.

this just means i will have to program around this......i was hoping to avoid this......

0 Kudos
Message 5 of 15
(8,815 Views)

the barcode scanner is a HID device and my PC sees it as a keyboard.


--- Perhaps LabVIEW does not.   I don't have an answer for that, but I'm sure of the rules I posted.

 

As a workaround, go back to the pre-event method and do polling:  every 100 mSec (for example), read the control, and compare it to the previous value (held in a shift register).  If the value is different, do something with the new value.

 

when i type a string from the keyboard the event only triggers when i press enter.

 

--- Most of the time, that's what you would want. For a numerical control, if I enter "1234" I don't want the event firing for "1" and then again for "12" and then again for "123" and then again for "1234" - that tells me the thing changed four times, when the user just wants to go to 1234. And what if I make a mistake and enter 1,2,3,5,backspace,4, then I get SIX events instead of one.

 

You can change that behavior, though - there's a boolean property called "Update Value While Typing", default FALSE.

 

Set that property TRUE (usually via right-click on the control) and you get the other behavior.

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 6 of 15
(8,814 Views)

the only problem is that the event will be triggered for every character of the barcode i.e. if i have a 10 character barcode the event will be triggered 10 times.

 

I don't understand what you want-  here you DON'T want 10 separate events, but earlier it was "annoying" that you got only one.

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 7 of 15
(8,812 Views)

 

when i type a string from the keyboard the event only triggers when i press enter. this is ok for entering a barcode from the keyboard

 

so if the user does need to enter the barcode from the keyboard for some reason (eg. not enough room for hand held scanner) he/she can press the enter key when the entire barcode has been entered.

however if the user needs to press the enter key or click on the front panel after ever scan of a barcode scanner that would be annoying.

i was going to use the barcode in the event

so if i had a barcode eg. 123456789, entering the event after 1 was entered then again when 2 was entered etc wouldn't make sense.

but if the only way is to set the "update while typing" property to high then i will have to work around that.

0 Kudos
Message 8 of 15
(8,806 Views)
Solution
Accepted by topic author loayn

Your barcodes are probably fixed length. When you get an event, check the length. If it matches the length of the barcode, then process the data, otherwise wait for more characters.  This can be handled very fast in the event case.

 

Lynn

Message 9 of 15
(8,802 Views)

i think thats what i will have to do......

0 Kudos
Message 10 of 15
(8,800 Views)