LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Automatic switching between two string inputs

Solved!
Go to solution

Hi guys, I have several string inputs on the front panel, which each should take an input from a barcode scanner.

 

What I want to do the VI to achieve is, jump to the next available string input, once one of the string input receives an input from the barcode scanner. (as shown in the transition from picture 1 to pic 2.)

 

Is this possible?

 

Cheers!

 

 

Picture 1

 

1.JPG

 

 

Picture 2

2.JPG

0 Kudos
Message 1 of 6
(3,586 Views)
Solution
Accepted by topic author jack@nz
You can use an event structure with a value change event. When the value of the control changes, meaning you scanned something, you can set focus to the next control you want to input your scan data.


Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 2 of 6
(3,584 Views)

One thing to watch out for is to check to see if the scanner appends a linefeed or other similar character to the string - you will likely need to strip this out.

 

Also, if the scanner is connected via a keyboard wedge, then as far as the LabVIEW VI is concerned, the characters would be coming in as if they were being typed in via the keyboard. That means that in order to see a value change event you will need to set the properties of the string control to "update value while typing". You can do this by right-clicking on the string control. This means that the event will be triggered for each character typed. Thus, you will need to determine when you've got the full code. Obviously, you will need to handle incomplete scans. 

 

If, on the other hand, the scanner is connected via a serial port, then you would know that you've received the full code once you see the termination character on the serial port. 

Message 3 of 6
(3,557 Views)
When ever I've used a barcode scanner I would set up the scanner to append a tab at the end of the scan.  This way it will go to the next control as if the operator pressed tab.  I would say look into the configuration of the scanner and see if you have that option.
Message 4 of 6
(3,544 Views)

Thanks guys for your feed back !

 

to Smercurio: thanks, this is useful as my barcode scanner plugs into a serial port 

 

to Hooovahh: what a shame I saw your post after I have implemented my VI using Mark's feed back, doing it your way would certainly have made it easier than what I have done.

 

 

Although the VI is working now, there is still one thing I am curioused about:

 

I have set the VI to set focus on the first string input when it starts. Now, this would work only if I run the VI from the front panel.

 

If I run  from the block diagram, the VI doesnt set focus on the first string input.

 

This is only for my curiousity, but does any one know why this is so?

 

Cheers! Smiley Happy

0 Kudos
Message 5 of 6
(3,529 Views)

jack@nz wrote:

 

I have set the VI to set focus on the first string input when it starts. Now, this would work only if I run the VI from the front panel.

 

If I run  from the block diagram, the VI doesnt set focus on the first string input.

 

This is only for my curiousity, but does any one know why this is so?

 

Cheers! Smiley Happy


I just verified that.  Running by clicking the run arrow on the block diagram makes the block diagram window come to the foreground.  Therefore, the focus means nothing because it is done on a window that is in the background.  If you click on the front panel and bring it to the foreground, the focus is NOT on the first string.  I would guess that the front panel string focus property was overwritten when the block diagram became in focus.  So the string focus is lost.

Lesson:  Use the run arrow on the front panel to run VIs involving setting focus on some front panel object.

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 6 of 6
(3,517 Views)