HELP Me
Configuration:
OS Chinese windowsXP
English Visual Foxpro v6.0
I try to use fread(),ASC(),CHR() function. I still didn't work it.
Below code from Microsoft:
* Transmitter Code.
* INIT event of Comm OLE control
* 28800 baud, no parity, 8 data, and 1 stop bit.
* In RS-232, maximum speed of 28800 baud can be used
This.Settings = "28800,N,8,1"
This.InputLen = 1
This.CommPort = 1
This.PortOpen = .T.
* ONCOMM event of Comm OLE Control
* The following code is needed to make sure that next set of characters
* can be transmitted (CommEvent = 2 is triggered from the receiver side)
IF This.CommEvent = 2
This.input
IF gnTop <= gnEnd
gcString = FREAD(gnFileHandle, 1) && Store to memory
q=asc(gcstring)
* change ASCII to character (size of 3) to preserve the lead char
thisform.olecontrol1.output = str(q,3)
gnTop = gnTop + 1
ENDIF
ENDIF
* INIT event of form
PUBLIC gnFileHandle
PUBLIC gnEnd
PUBLIC gnTop
PUBLIC q
* You should replace 'c:\sample.hlp' with your own binary file
STORE FOPEN('c:\sample.hlp') TO gnFileHandle && Open the file
STORE FSEEK(gnFileHandle, 0, 2) TO gnEnd && Move pointer to EOF
STORE FSEEK(gnFileHandle, 0) TO gnTop && Move pointer to BOF
gntop=1
q=""
-----------------------
Property of OleControl1
RThreshold = 1 * triggers when at least one char is on the buffer
SThreshold = 3
-----------------------
* Receiver Code.
* INIT event of OleControl1
* 28800 baud, no parity, 8 data, and 1 stop bit.
This.Settings = "28800,N,8,1"
This.InputLen = 3
This.CommPort = 1
This.PortOpen = .T.
* OnComm event
IF This.CommEvent = 2 AND This.InBufferCount > 0
qq=CHR(VAL(This.Input))
=FWRITE(gnFileHandle,qq)
this.output = CHR(26)
ENDIF
* INIT event of form
PUBLIC gnFileHandle
* You should replace 'c:\sample.hlp' with your own file name
IF FILE('c:\sample.hlp') && Does file exist?
gnErrFile = FOPEN('c:\sample.hlp',12) && If so, open read-write
ELSE
gnErrFile = FCREATE('c:\sample.hlp') && If not, create it
ENDIF
= FCLOSE(gnErrFile) && Close the file
STORE FOPEN('c:\sample.hlp',1) TO gnFileHandle && Open the file
* CLICK event of button
*This tells the transmitting side to start sending the file
Thisform.Olecontrol1.output = CHR(26)
-----------------------
Property of OleControl1
RThreshold = 3
Configuration:
OS Chinese windowsXP
English Visual Foxpro v6.0
I try to use fread(),ASC(),CHR() function. I still didn't work it.
Below code from Microsoft:
* Transmitter Code.
* INIT event of Comm OLE control
* 28800 baud, no parity, 8 data, and 1 stop bit.
* In RS-232, maximum speed of 28800 baud can be used
This.Settings = "28800,N,8,1"
This.InputLen = 1
This.CommPort = 1
This.PortOpen = .T.
* ONCOMM event of Comm OLE Control
* The following code is needed to make sure that next set of characters
* can be transmitted (CommEvent = 2 is triggered from the receiver side)
IF This.CommEvent = 2
This.input
IF gnTop <= gnEnd
gcString = FREAD(gnFileHandle, 1) && Store to memory
q=asc(gcstring)
* change ASCII to character (size of 3) to preserve the lead char
thisform.olecontrol1.output = str(q,3)
gnTop = gnTop + 1
ENDIF
ENDIF
* INIT event of form
PUBLIC gnFileHandle
PUBLIC gnEnd
PUBLIC gnTop
PUBLIC q
* You should replace 'c:\sample.hlp' with your own binary file
STORE FOPEN('c:\sample.hlp') TO gnFileHandle && Open the file
STORE FSEEK(gnFileHandle, 0, 2) TO gnEnd && Move pointer to EOF
STORE FSEEK(gnFileHandle, 0) TO gnTop && Move pointer to BOF
gntop=1
q=""
-----------------------
Property of OleControl1
RThreshold = 1 * triggers when at least one char is on the buffer
SThreshold = 3
-----------------------
* Receiver Code.
* INIT event of OleControl1
* 28800 baud, no parity, 8 data, and 1 stop bit.
This.Settings = "28800,N,8,1"
This.InputLen = 3
This.CommPort = 1
This.PortOpen = .T.
* OnComm event
IF This.CommEvent = 2 AND This.InBufferCount > 0
qq=CHR(VAL(This.Input))
=FWRITE(gnFileHandle,qq)
this.output = CHR(26)
ENDIF
* INIT event of form
PUBLIC gnFileHandle
* You should replace 'c:\sample.hlp' with your own file name
IF FILE('c:\sample.hlp') && Does file exist?
gnErrFile = FOPEN('c:\sample.hlp',12) && If so, open read-write
ELSE
gnErrFile = FCREATE('c:\sample.hlp') && If not, create it
ENDIF
= FCLOSE(gnErrFile) && Close the file
STORE FOPEN('c:\sample.hlp',1) TO gnFileHandle && Open the file
* CLICK event of button
*This tells the transmitting side to start sending the file
Thisform.Olecontrol1.output = CHR(26)
-----------------------
Property of OleControl1
RThreshold = 3