Way to read from USB port with Rev (Bar Code Reader)

Sarah Reichelt sarah.reichelt at gmail.com
Sun Jan 14 17:46:01 EST 2007


On 1/14/07, Peter Alcibiades <palcibiades-first at yahoo.co.uk> wrote:
> "say, can you tell me which barcode reader you've tried this with?"
>
> Sure, its a Datalogic Gryphon.  Any reader which uses a Y cable to connect
> should work however.
>
> The only problem I can see with this method is that you have to ensure that
> the window in which your data is going to be entered has focus.  And if the
> user does something with the mouse or keyboard, those events will be
> registered as well.  So maybe some sort of script is necessary when the Rev
> application is opened that somehow locks down the input.  If its for your own
> use rather than in a production environment that shouldn't be an issue.
>
> The Gryphon is a nice piece of gear.  You press the trigger.  A light bar
> shines out of the scanner end.  You move the light bar to the bar code, it
> beeps, a green light appears, and the data appears in the field.   Pretty
> robust and available used quite cheaply.
>

I use various barcode scanners (Datalogic, Unitech, Symbol) and they
all operate in the same manner - as a keyboard wedge. When the barcode
is scanned, the text of the code is sent to the computer exactly as if
the keys were being pressed, so as Peter says, you have to make sure
your application has the focus  - I have had the occasional problem
were the hard drive has been renamed :-)

Apart from that, I use the following scripts:

on keyDown theKey
    if the short name of this Stack = "vicMain" then
        if the hilite of btn "readCodes" of cd 1 then
            put theKey after fld "Barcode"
        else
            pass keyDown
        end if
    else
        pass keyDown
    end if
end keyDown

on rawKeyDown theKey
    if the short name of this Stack = "vicMain" then
        if theKey = 65293 and the hilite of btn "readCodes" of cd 1 then
            autoLog "Scan: " & fld "Barcode"
            put the short name of this card into cardName
            send "processBarcode" to cd cardName
        else
            pass rawKeyDown
        end if
    else
        pass rawKeyDown
    end if
end rawKeyDown


The keyDown script stores any text coming from the barcode scanner.
When the scanner finishes reading a code, it sends a key code of 65293
which is spotted by the rawKeyDown handler, which calls the relevant
script to handle the complete barcode.

I have a stack <http://www.troz.net/Rev/misc/BarcodeTester.rev.gz>
that tests the data coming from a barcode scanner, which you might
find useful.

Cheers,
Sarah



More information about the use-livecode mailing list