C
cc007sy
Unregistered / Unconfirmed
GUEST, unregistred user!
偶建了一个数组
COM_HEAD=record
TXN_CODE:array[1..7] of char;
RET_CODE:array[1..4] of char;
REC_NUM:array[1..4] of char;
TXN_TYPE:array[1..1] of char;
TXN_DATE:array[1..8] of char;
TXN_BNCH:array[1..4] of char;
TXN_TLR:array[1..4] of char;
TXN_TERM:array[1..4] of char;
然后用一个函数从一个字符串中取职,函数如下
function getstringbyindex(buffer:string;index:integer;len:integer):string;
var
return:string;
i:integer;
begin
return:='';
for i:=index to index+len-1 do
begin
return:=return+char(buffer);
end;
result:=return;
end;
然后我取的时候是这么写的
var
s:string;
begin:
s:='dfasssssssssohoijhoidjsafjijdso';
com_head_rec.TXN_CODE:=getstringbyindex(s,1,7);
com_head_rec.RET_CODE:=getstringbyindex(s,8,4);
com_head_rec.REC_NUM :=getstringbyindex(s,12,4);
com_head_rec.TXN_TYPE:=getstringbyindex(s,16,1);
com_head_rec.TXN_DATE:=getstringbyindex(s,17,8);
com_head_rec.TXN_BNCH:=getstringbyindex(s,25,4);
com_head_rec.TXN_TLR:=getstringbyindex(udprecv,29,4);
com_head_rec.TXN_TERM:=getstringbyindex(udprecv,33,4);
end;
可是老是提示错误incompatible types:'array'and 'string'.
偶是初学
请大家指教。
COM_HEAD=record
TXN_CODE:array[1..7] of char;
RET_CODE:array[1..4] of char;
REC_NUM:array[1..4] of char;
TXN_TYPE:array[1..1] of char;
TXN_DATE:array[1..8] of char;
TXN_BNCH:array[1..4] of char;
TXN_TLR:array[1..4] of char;
TXN_TERM:array[1..4] of char;
然后用一个函数从一个字符串中取职,函数如下
function getstringbyindex(buffer:string;index:integer;len:integer):string;
var
return:string;
i:integer;
begin
return:='';
for i:=index to index+len-1 do
begin
return:=return+char(buffer);
end;
result:=return;
end;
然后我取的时候是这么写的
var
s:string;
begin:
s:='dfasssssssssohoijhoidjsafjijdso';
com_head_rec.TXN_CODE:=getstringbyindex(s,1,7);
com_head_rec.RET_CODE:=getstringbyindex(s,8,4);
com_head_rec.REC_NUM :=getstringbyindex(s,12,4);
com_head_rec.TXN_TYPE:=getstringbyindex(s,16,1);
com_head_rec.TXN_DATE:=getstringbyindex(s,17,8);
com_head_rec.TXN_BNCH:=getstringbyindex(s,25,4);
com_head_rec.TXN_TLR:=getstringbyindex(udprecv,29,4);
com_head_rec.TXN_TERM:=getstringbyindex(udprecv,33,4);
end;
可是老是提示错误incompatible types:'array'and 'string'.
偶是初学
请大家指教。