procedure timer If Thisform.mymscomm.InBufferCount>0 =Thisform.mymscomm.Olecontrol1.oncomm() Endif endprocThis example receives some data from the COMx: port e send it to the keyboard (simulating the keyboard wand for some Barcodes readers)
procedure oncomm If This.CommEvent = 2 && there is acctivity there cbufferscanner="" wlen=0 Do While this.InBufferCount > 0 cbufferscanner=cbufferscanner+This.Input wlen=len(alltrim(cbufferscanner)) If AT(CHR(10),Thisformset.bufferscanner)>0 && it's a LF that meaning the end of my data Do while AT(CHR(10),cbufferscanner)>0 cbufferscanner=STUFF(cbufferscanner,AT(CHR(10),cbufferscanner),1,"") Enddo wlen=len(alltrim(cbufferscanner)) Endif If wlen>0 WSCANNER=substr(cbufferscanner,1,wlen) cbufferscanner=stuff(cbufferscanner,1,wlen,"") Thisformset.LVEMSCANNER=.T. && warnning for the rest of the application that exists acctivity from scanner Keyboard WSCANNER && Keyboard entry simulation Endif Enddo Endif Endif Return endprocThis will work perfectly in all Windows systems. And, you must setup some properties on mscomm32 to handle with your external device (data speed, communication port in use, stop bits, parity, etc.)