I/O ActiveX Users Forum

I/O ActiveX Home Page
I/O ActiveX Users Forum


Name=Barcode Foxpro

Subject=Serial Port Communications

The following code from the class browser of a quick test form
should give you an idea of how to capture your barcode to an editbox.
The data is stored in THISFORM.inbuffer and will have to be parsed and
cleared by code you provide. HTH

DEFINE CLASS frm1 AS frm
Top = 0
Left = 0
Height = 242
Width = 362
DoCreate = .T.
Caption = "Read IO"
Name = "Frm1"
inbuffer = .F.

ADD OBJECT io1 AS olecontrol WITH ;
Top = 12, ;
Left = 264, ;
Height = 100, ;
Width = 100, ;
Name = "IO1"

ADD OBJECT cmg1 AS cmg WITH ;
ButtonCount = 3, ;
BorderStyle = 1, ;
Height = 37, ;
Left = 108, ;
Top = 180, ;
Width = 143, ;
Name = "Cmg1", ;
Command1.Top = 5, ;
Command1.Left = 5, ;
Command1.Height = 27, ;
Command1.Width = 43, ;
Command1.Caption = "\<Start", ;
Command1.Name = "Command1", ;
Command2.Top = 5, ;
Command2.Left = 50, ;
Command2.Height = 27, ;
Command2.Width = 43, ;
Command2.Caption = "S\<top", ;
Command2.Name = "Command2", ;
Command3.Top = 5, ;
Command3.Left = 95, ;
Command3.Height = 27, ;
Command3.Width = 43, ;
Command3.Caption = "E\<xit", ;
Command3.Name = "Command3"

ADD OBJECT edt1 AS edt WITH ;
Height = 132, ;
Left = 24, ;
Top = 24, ;
Width = 312, ;
ControlSource = "THISFORM.inbuffer", ;
Name = "Edt1"

PROCEDURE Init
THIS.inbuffer = ""
ENDPROC
 

PROCEDURE io1.IOQueueEvent
*** ActiveX Control Event ***
LPARAMETERS numcharsinputque, numcharsoutputque

WITH THISFORM
IF THIS.numcharsinque>0
numchars = THIS.numcharsinque
.inbuffer = .inbuffer + THIS.readdata(numchars)
.edt1.REFRESH()
ENDIF
ENDWITH
ENDPROC
 

PROCEDURE cmg1.Command1.Click
LOCAL lnopenok,lnhsok

WITH THISFORM
lnopenok = .io1.OPEN("COM1","baud=9600 parity=N data=8 stop=1")
DO CASE
CASE lnopenok = 0
=MESSAGEBOX("Open Failed",0)
CASE lnopenok = 2
=MESSAGEBOX("Port already in use.",4)
ENDCASE
lnhsok = .IO1.sethandshaking(2)
IF lnhsok = 0
=MESSAGEBOX("Set HS Failed",0)
=.io1.CLOSE()
ENDIF
ENDWITH
ENDPROC
 

PROCEDURE cmg1.Command2.Click
=THISFORM.IO1.Close()
ENDPROC
 

PROCEDURE cmg1.Command3.Click
=THISFORM.IO1.Close()
THISFORM.RELEASE
ENDPROC
 

ENDDEFINE
 

Jim Livermore
jjelec@odyssey.net
 
 
 


Respond or Add your comment, experience, advice to the Users Forum.