DELPHI盒子
!实时搜索: 盒子论坛 | 注册用户 | 修改信息 | 退出
检举帖 | 全文检索 | 关闭广告 | 捐赠
技术论坛
 用户名
 密  码
自动登陆(30天有效)
忘了密码
≡技术区≡
DELPHI技术
lazarus/fpc/Free Pascal
移动应用开发
Web应用开发
数据库专区
报表专区
网络通讯
开源项目
论坛精华贴
≡发布区≡
发布代码
发布控件
文档资料
经典工具
≡事务区≡
网站意见
盒子之家
招聘应聘
信息交换
论坛信息
最新加入: aaaarrrrrrrrrrrr
今日帖子: 57
在线用户: 3
导航: 论坛 -> DELPHI技术 斑竹:liumazi,sephil  
作者:
男 zz791224 (zz791224) ★☆☆☆☆ -
盒子活跃会员
2004/5/6 14:45:07
标题:
求助几个函数的问题!!!! 浏览:1223
加入我的收藏
楼主: 谁可以给出我介绍一下HEXTOBIN(),READFILE(),WRITEFILE()函数呀,最好有代码!
此外,用什么函数可以查到一个字符的ascii码,什么函数可可以把一个十六进制的数转换成二进制的数呀?谢谢了!!
----------------------------------------------
-
作者:
男 bios (阿贡) ★☆☆☆☆ -
盒子中级会员
2004/5/6 16:24:49
1楼: 1)HEXTOBIN:
procedure TForm1.Button1Click(Sender: TObject);
const ab='22';
 cd='3231';
var
 size,size2:longint;
 buffer:Pchar;
 Text:Pchar;
begin
 size:=length(trim(ab));
 
 size2:=2*length(trim(ab));
 getmem(text,size2);
 BinToHex(Pchar(ab), Text,Size);
 edit1.Text :=strpas(text);
 freemem(text);
 
 
 
  
 getmem(buffer,size);
 size2:=2*length(trim(cd));
 size:=size2 div 2;
 getmem(text,size2);
 HexToBin(Pchar(cd), buffer,Size);
 edit2.Text :=strpas(Buffer);
 freemem(text);
 freemem(buffer);
end;

2)3)还没做过
4)ord('a')=97
5)HEXTOBIN() 不就是了 难道你不会英语?
----------------------------------------------
按此在新窗口浏览图片
按此在新窗口浏览图片
作者:
男 zz791224 (zz791224) ★☆☆☆☆ -
盒子活跃会员
2004/5/7 0:49:26
2楼: HEXTOBIN()此函数转换过来怎么老不对呀,二进制的应该是1或0呀,怎么老显示出其它的数字呀??
----------------------------------------------
-
作者:
男 bios (阿贡) ★☆☆☆☆ -
盒子中级会员
2004/5/7 8:12:30
3楼: 不好意思 昨天很急,所以忘记了 系统自带不好 自己写个好!

function convert1(st:string):string;
begin
  if st='0000' then Result:='0';
  if st='0001' then Result:='1';
  if st='0010' then Result:='2';
  if st='0011' then Result:='3';
  if st='0100' then Result:='4';
  if st='0101' then Result:='5';
  if st='0110' then Result:='6';
  if st='0111' then Result:='7';
  if st='1000' then Result:='8';
  if st='1001' then Result:='9';
  if st='1010' then Result:='A';
  if st='1011' then Result:='B';
  if st='1100' then Result:='B';
  if st='1101' then Result:='C';
  if st='1110' then Result:='D';
  if st='1111' then Result:='E';
end;
 
function convert2(st:string):string;
begin
  if st='0' then Result:='0000';
  if st='1' then Result:='0001';
  if st='2' then Result:='0010';
  if st='3' then Result:='0011';
  if st='4' then Result:='0100';
  if st='5'  then Result:='0101' ;
  if st='6' then Result:='0110';
  if st='7' then Result:='0111';
  if st='8' then Result:='1000';
  if st='9' then Result:='1001';
  if st='A' then Result:='1010';
  if st='B' then Result:='1011';
  if st='B'then Result:='1100' ;
  if st='C' then Result:='1101';
  if st='D' then Result:='1110';
  if st='E' then Result:='1111';
end;
procedure TForm1.Button3Click(Sender: TObject);
var
 s,t,s1:string;
 i,j:Longint;
begin
s:=trim(edit3.Text );
j:=length(s);
t:='';
while j>0 do
 begin
   s1:=convert1(copy(s,1,4));
   delete(s,1,4);
   dec(j,4);
   t:=t+s1;
 end;
 edit4.Text :=t;
end;
 
procedure TForm1.Button4Click(Sender: TObject);
var
 s,t,s1:string;
 i,j:Longint;
begin
 s:=trim(edit5.Text );
j:=length(s);
t:='';
i:=1;
 while i<=j do
  begin
    s1:=convert2(copy(s,i,1));
    inc(i);
    t:=t+s1;
  end;
  edit6.Text :=t;
end;
----------------------------------------------
按此在新窗口浏览图片
按此在新窗口浏览图片
信息
登陆以后才能回复
Copyright © 2CCC.Com 盒子论坛 v3.0.1 版权所有 页面执行70.3125毫秒 RSS