一个串口MSCOMM通信的问题,急!!!!!!!!(高手进) ( 积分: 50 )

  • 主题发起人 主题发起人 yang_9999_520
  • 开始时间 开始时间
Y

yang_9999_520

Unregistered / Unconfirmed
GUEST, unregistred user!
为了获得售电机的地区码,在MSCOMM中添加如下代码(是用VFP写的):
string1="1288888812345678&quot
&&wxly
do Case thisform.MSComm1.CommEvent
Case thisform.MSComm1.CommEvent=2 &&amp
收到 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="?&quot

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 = "|&quot

if len(allt(thisform.text4.value))<16
WAIT WINDOWS&quot;读售电机地区码出错&quot;
return
else
WAIT WINDOWS &quot;本售电机地区码=&quot;+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=&quot;/<C继续&quot

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)它的功能是&quot;Returns a number corresponding to the first mouse click or key press in the type-ahead buffer.&quot;
请问在Delphi中应该用什么函数能代替它的功能?因为小弟是Delphi菜鸟,肯请高手不吝赐教!!
 
为了获得售电机的地区码,在MSCOMM中添加如下代码(是用VFP写的):
string1=&quot;1288888812345678&quot
&amp;&amp;wxly
do Case thisform.MSComm1.CommEvent
Case thisform.MSComm1.CommEvent=2 &amp;&amp
收到 RThreshold # of
do case flag
case flag=0
inbuf=thisform.MSComm1.Input
do case inbuf
case inbuf=&quot;@&quot;
thisform.MSComm1.OutBufferCount = 0
thisform.MSComm1.inBufferCount=0
thisform.MSComm1.Output =&quot;S&quot;
case inbuf=&quot;S&quot;
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)&amp;&amp;send data
ENDFOR
thisform.MSComm1.Output=chr(0)
flag=1
=inkey(1)
thisform.MSComm1.OutBufferCount=0
thisform.MSComm1.inBufferCount=0
thisform.MSComm1.output=&quot;?&quot

endcase
case flag=1
InBuf = thisform.MSComm1.Input
thisform.text4.value=thisform.text4.value+InBuf
DO CASE inbuf
case InBuf = &quot;@&quot;
tt=tt+1
thisform.MSComm1.output=&quot;G&quot;
CASE InBuf = &quot;|&quot

if len(allt(thisform.text4.value))<16
WAIT WINDOWS&quot;读售电机地区码出错&quot;
return
else
WAIT WINDOWS &quot;本售电机地区码=&quot;+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=&quot;/<C继续&quot

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)它的功能是&quot;Returns a number corresponding to the first mouse click or key press in the type-ahead buffer.&quot;
请问在Delphi中应该用什么函数能代替它的功能?因为小弟是Delphi菜鸟,肯请高手不吝赐教!!
 
后退
顶部