procedure TForm2.Button1Click(Sender: TObject);
var s,s2 :String;
    chValue :Integer;
    RF :TextFile;
    commArray :Array[0..457] of Char;
    I:Integer;
begin
   AssignFile(RF,'c:\1.txt');
   Reset(RF);
   ReadLn(RF,s);
   //showmessage(inttostr(length(s)));
   edit1.Text :='';
   edit2.Text :='';
   edit3.Text:='';
   for I := 221 to Length(s) - 2 do
   begin
     edit1.Text := edit1.Text + ','+ intToStr(binToDec(intToStr(ORD(copy(s,i,1)))));
     edit2.Text := edit2.Text + ','+ intToStr(ORD(copy(s,i,1)));
     edit3.Text := edit3.Text + copy(s,i,1);
     edit4.Text := intToStr(ord(copy(s,i,1)));
     if i = Length(s)-1 then
        showmessage(copy(s,i,1)+':'+inttoStr(i));
   end;
   closeFile(RF);
end;
我edit3.text每次取到的值是一样的,为什么 我edit2.text每次得到的值不一样? 
我的c:\1.txt的内容是固定的。
我的1.txt内容如下:
09/ 4/2511:32 000000000011Z 2褧?z@hz渀?x寗c??J  5.0 4.65  1490.414 89.0 32.0  360  1220.4120.0960.492  2.1  0.5  2.40.120 39.6 13.2  9.90.252 66.3186.6                                                       &ZdG!    #%((" 

解决方案 »

  1.   

    edit1.Text := edit1.Text + ','+ intToStr(binToDec(intToStr(ORD(copy(s,i,1))))); 
    --
    ORD(copy(s,i,1)) 
    楼主你可以这样用吗?copy返回的是一个String类型的,放在Ord里面编译不过的。
      

  2.   

    function Copy(S; Index, Count: Integer): string;ORD(copy(s,i,1)) 应该编译通不过的,
    按楼主的意思应该这样去写吧
    ORD(s[i])
    copy(s,i,1) 不就是想取第i个字符嘛,s[i] 不是更简单
      

  3.   

    Ord 返回参数值在其数据类型值集合中的序号Delphi syntax:function Ord(X);DescriptionX is a Delphi ordinal-type expression. The result is the ordinal position of X; its type is the smallest standard integer type that can hold all values of X's type.Ord cannot operate on Int64 values.