Jamie:
Here is some sample code that I have used to test barcode scanners. It is somewhat incomplete, but it should give you a good start.
HTH,
--Paul
{Init}
THISFORM.xScanner.CommPort = 1
THISFORM.xScanner.Settings = "9600,s,7,2"
THISFORM.xScanner.PortOpen = .T.
{OnComm Event}
lnCommError = This.CommEvent
IF INLIST(lnCommError,1001,1002,1003,1004,1006,1008,1009,1010,1011)
= MESSAGEBOX("Communication Problem")
RETURN
ENDIF
* Get the scan input
lcInput = THIS.Input
* Save the scan input and add it to our global variable
gcInput = gcInput + lcInput
* Determine if there is a CR and LF in the current global scan variable
lnScan = AT(CHR(13)+CHR(10),gcInput,1)
* There is no CR and LF in the global scan, so return
IF lnScan = 0
RETURN
ENDIF
* Are there more than one set of CR and LF. If so, then this is an
* invalid scan. This should only happen if there is some wait
* state that is not processing READ EVENTS and the user scans
* a barcode. For example: there is a WAIT WINDOW
and the user
* scans a bar code while this WAIT WINDOW is on the screen.
IF AT(CHR(13)+CHR(10), gcInput, 2) > 0
= MESSAGEBOX("You have a invalid scan. Please try again.")
gcInput = ""
RETURN
ENDIF
* Remove the CR and LF
lcScanID = LEFT(gcInput, lnScan - 1)
* This is where we can work with our scanned in bar code
IF NOT EMPTY(lcScanID)
IF This.ParityReplace $ lcScanID
MESSAGEBOX("A parity error has happened")
ENDIF
WAIT WINDOW NOWAIT "Barcode is: "+lcScanID
gcInput = ""
ENDIF
>I have a barcode scanner with a built in decoder, plugged into Com1.
>
>I'm trying to read the barcode that was swiped, and enter the contents into a textbox on a form. I can not get the OnComm event to fire.
>
>Any help would be much appreciated.
>
>Thanks.
>
>Jamie
>jamie@s-d-x.com