//附上源代码,用途按指定格式处理数据,并赋到目的串dest
function ArrCharCopy(Sour:string;SType:String;len_sour:integer;dest
Char;pos_dest:Integer):Integer;
var
m_loop,i_times,i_temp,len_name:Integer;
s_temp:string;
buf:TArrayCharDef;//一个足够长的字符串类
begin
//16进制的string
if SType='hex' then
begin
HexToBin(Pchar(Sour),@buf,len_sour);
end
//2进制的string
else if SType='bin' then
begin
i_temp:=BinStrToInt32(Sour);
s_temp:=IntToHex(i_temp,len_sour);
HexToBin(Pchar(s_temp),@buf,len_sour);
end;
if (SType='hex') or (SType='bin') then
begin
i_times:=(len_sour div 2) - 1;
for m_loop:=0 to i_times do
begin
dest[pos_dest]:=buf[m_loop];
pos_dest:= pos_dest + 1;//问题出现处????????
end;
Result:=i_times + 1;
Exit;
end;
//asc码字符串
if SType='str' then
begin
len_name:=Length(sour);
i_times:= len_name - 1;
for m_loop := 0 to i_times do
begin
//字符串从1开始记数
dest[pos_dest]:=sour[m_loop + 1];
pos_dest:= pos_dest + 1;
end;
i_times:= len_sour - len_name - 1;
//名称结束补零
for m_loop := 0 to i_times do
begin
dest[pos_dest]:=#0;
pos_dest:= pos_dest + 1;
end;
//返回增加数据
Result:=len_sour;
Exit;
end;
//数据处理结束
end;