位操作出错: Incompatible types: 'String' and 'Integer' ( 积分: 10 )

  • 主题发起人 主题发起人 gxpcw
  • 开始时间 开始时间
G

gxpcw

Unregistered / Unconfirmed
GUEST, unregistred user!
运行到该句.......HexToAscii((IntToHex(cmd,&nbsp;2)&nbsp;shr&nbsp;4)&nbsp;and&nbsp;$0F);出错<br>其中定义:cmd:integer<br>Function&nbsp;HexToAscii(SourceStr:&nbsp;WideString):&nbsp;WideString;<br>var&nbsp;str:string;<br>&nbsp;&nbsp;&nbsp;&nbsp;text:string;<br>&nbsp;&nbsp;&nbsp;&nbsp;BX:string;<br>begin<br>&nbsp;&nbsp;while&nbsp;length(SourceStr)&lt;&gt;0&nbsp;do<br>&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;str:=copy(SourceStr,1,2);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;text:=text+chr(ord(strtoint('$'&nbsp;+&nbsp;str)));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;delete(SourceStr,1,2);<br>&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;result:=text;<br>end;
 
HexToAscii((IntToHex(cmd,&nbsp;2)&nbsp;shr&nbsp;4)&nbsp;and&nbsp;$0F);<br>分解后是:<br>IntToHex(cmd,&nbsp;2)&nbsp;--&gt;&nbsp;结果是&nbsp;string&nbsp;类型<br>string&nbsp;shr&nbsp;4&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;--&gt;&nbsp;移谁好呢?电脑顿时傻了<br><br>要把你的理解,通俗地告诉电脑才行。
 
看楼主的意思就是想把cmd转为16进制后shr&nbsp;4&nbsp;再&nbsp;and&nbsp;$0F?<br>直接做就行,不用转成16进制,在内存里都是2进制存在的,所以integer和HEX都只是表现而已<br>你这样就行HexToAscii((cmd&nbsp;shr&nbsp;4)&nbsp;and&nbsp;$0F);
 
楼上的语句:HexToAscii((cmd&nbsp;shr&nbsp;4)&nbsp;and&nbsp;$0F);也不行,<br>.....<br>var&nbsp;command&nbsp;:&nbsp;string;<br>....<br>command:=HexToAscii((cmd&nbsp;shr&nbsp;4)&nbsp;and&nbsp;$0F);<br>还是出错:&nbsp;Incompatible&nbsp;types:&nbsp;'String'&nbsp;and&nbsp;'Integer'
 
啊?&nbsp;哦......汗.......不好意思<br>HexToAscii(inttohex((cmd&nbsp;shr&nbsp;4)&nbsp;and&nbsp;$0F));
 
后退
顶部