07-23-2009 09:41 AM
A barcode scanner connected as a keyboard does not require the input device controls. Just like you would use a string control to ask a user to enter something from the keyboard, a string control is all you need for the scanner. Below is about the simplest method to read a scanner. If the scanner is set to append a CR at the end of the scan and if the Ok button's key navigation is set to toggle on the return key, it's all that you need. An event structure works just as well.
07-23-2009 11:32 AM
That's surely right. But what if the control isn't on the main VI front panel? How can I activate it?
My idea was to build a subVI like the one I used for the serial ports, but I found some problems in doing it (I've difficulties at reconstructing the string). I post the code, even if I know there are some mistakes (the use of the queues is just a trial).
Thanks!
07-23-2009 02:44 PM
07-23-2009 02:49 PM
Ahah.. I got it.
I explain you my problem. If I put the string control in a subVI, how to activate the reading process? If I want to write on a control, I have to pass over it and click with the mouse in order to activate it. If I don't see it on the screen and I don' have a mouse, how can I write with the keyboard??
07-23-2009 03:34 PM - edited 07-23-2009 03:36 PM
You would use a KeyFocus property. The attached VI is an old one that I've used. I now use an event structure and some validating to the bar code to make sure the correct one has been scanned but this one should get you started. The stop button can be hidden. the VI will stop as soon as the enter key is detected and you can program scanners to send that at the end. Because I made the VI a dialog, the front panel will popup whenever it is called.
07-23-2009 04:08 PM
Thanks, you made me discover this function. Being totally new to this programming environment, I lost one afternoon on this and how I discover how easy it was! But I think it's normal.
Now I'll go on with my program, I've to make the three instruments send the data to the main program, which has to check and analyze them. Just one question about it: the analysis about the data (with a grenn/yellow/red display on the front panel) should be done in the sub-Vi or in the main after having taken them out of the queue?
Thanks a lot for your help! I'm really getting involved with this programming environment 🙂
07-24-2009 03:25 AM
Using the key focus I still have 2 problems:
1. If I don't use a pop-up panel, the first time the program executes the controls aren't enabled;
2. How to get the string at the indicator?
tks