Y
yang_9999_520
Unregistered / Unconfirmed
GUEST, unregistred user!
为了获得售电机的地区码,在MSCOMM中添加如下代码(是用VFP写的):
string1="1288888812345678"
&&wxly
do Case thisform.MSComm1.CommEvent
Case thisform.MSComm1.CommEvent=2 &&
收到 RThreshold # of
do case flag
case flag=0
inbuf=thisform.MSComm1.Input
do case inbuf
case inbuf="@"
thisform.MSComm1.OutBufferCount = 0
thisform.MSComm1.inBufferCount=0
thisform.MSComm1.Output ="S"
case inbuf="S"
FOR I=1 TO 16 STEP 1
thisform.MSComm1.OutBufferCount = 0
thisform.MSComm1.inBufferCount=0
thisform.MSComm1.Output=SUBS(STRING1,i,1)
thisform.text2.value=thisform.text2.value+subs(string1,i,1)&&send data
ENDFOR
thisform.MSComm1.Output=chr(0)
flag=1
=inkey(1)
thisform.MSComm1.OutBufferCount=0
thisform.MSComm1.inBufferCount=0
thisform.MSComm1.output="?"
endcase
case flag=1
InBuf = thisform.MSComm1.Input
thisform.text4.value=thisform.text4.value+InBuf
DO CASE inbuf
case InBuf = "@"
tt=tt+1
thisform.MSComm1.output="G"
CASE InBuf = "|"
if len(allt(thisform.text4.value))<16
WAIT WINDOWS"读售电机地区码出错"
return
else
WAIT WINDOWS "本售电机地区码="+subs(thisform.text4.value,9,8) timeout 5
endif
if used('s_szqx')
select s_szqx
else
use s_szqx in 0
endif
goto recno()
thisform.command2.caption="/<C继续"
OTHERWISE
thisform.MSComm1.OutBufferCount = 0
thisform.MSComm1.InBufferCount = 0
thisform.MSComm1.output=inBuf
tt=tt+1
if tt=9
thisform.MSComm1.OutBufferCount = 0
thisform.MSComm1.InBufferCount = 0
thisform.MSComm1.Output=chr(0)
endif
ENDCASE
endcase
endcase
在上面代码中用到了函数(inkey)它的功能是"Returns a number corresponding to the first mouse click or key press in the type-ahead buffer."
请问在Delphi中应该用什么函数能代替它的功能?因为小弟是Delphi菜鸟,肯请高手不吝赐教!!
string1="1288888812345678"
&&wxly
do Case thisform.MSComm1.CommEvent
Case thisform.MSComm1.CommEvent=2 &&
收到 RThreshold # of
do case flag
case flag=0
inbuf=thisform.MSComm1.Input
do case inbuf
case inbuf="@"
thisform.MSComm1.OutBufferCount = 0
thisform.MSComm1.inBufferCount=0
thisform.MSComm1.Output ="S"
case inbuf="S"
FOR I=1 TO 16 STEP 1
thisform.MSComm1.OutBufferCount = 0
thisform.MSComm1.inBufferCount=0
thisform.MSComm1.Output=SUBS(STRING1,i,1)
thisform.text2.value=thisform.text2.value+subs(string1,i,1)&&send data
ENDFOR
thisform.MSComm1.Output=chr(0)
flag=1
=inkey(1)
thisform.MSComm1.OutBufferCount=0
thisform.MSComm1.inBufferCount=0
thisform.MSComm1.output="?"
endcase
case flag=1
InBuf = thisform.MSComm1.Input
thisform.text4.value=thisform.text4.value+InBuf
DO CASE inbuf
case InBuf = "@"
tt=tt+1
thisform.MSComm1.output="G"
CASE InBuf = "|"
if len(allt(thisform.text4.value))<16
WAIT WINDOWS"读售电机地区码出错"
return
else
WAIT WINDOWS "本售电机地区码="+subs(thisform.text4.value,9,8) timeout 5
endif
if used('s_szqx')
select s_szqx
else
use s_szqx in 0
endif
goto recno()
thisform.command2.caption="/<C继续"
OTHERWISE
thisform.MSComm1.OutBufferCount = 0
thisform.MSComm1.InBufferCount = 0
thisform.MSComm1.output=inBuf
tt=tt+1
if tt=9
thisform.MSComm1.OutBufferCount = 0
thisform.MSComm1.InBufferCount = 0
thisform.MSComm1.Output=chr(0)
endif
ENDCASE
endcase
endcase
在上面代码中用到了函数(inkey)它的功能是"Returns a number corresponding to the first mouse click or key press in the type-ahead buffer."
请问在Delphi中应该用什么函数能代替它的功能?因为小弟是Delphi菜鸟,肯请高手不吝赐教!!