多维动态数组的问题,运行出错,请帮帮忙(50分)

  • 主题发起人 主题发起人 孤星2005
  • 开始时间 开始时间

孤星2005

Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TForm1.CreateData;
var s:string;
off:integer;
len,i,j,k,n,ptr:integer;
dot_old_buff,dot_new_buff : array [0..31] of byte;
dot_asc_old, dot_asc_new : array [0..15] of byte;
//ascstr:string;
//temp,tmp:string;
begin
s := SeSkinEdit1.Text;
SetLength(DataBuf, Length(SeSkinEdit1.Text));
StrList.Clear;
len:=1;
ptr := 0;
While len<= Length(s) do
begin
if ((ord(s[len])> 127) and boolean(byte(s[len+1]) and $80)) then
begin
off:=((byte(s[len])-$a1) and $7f) * 94 + ((byte(s[len+1])-$a1) and $7f);
off :=off*32;
for i := 0 to 31 do
begin
dot_old_buff := phzk[off+i];
dot_new_buff := 0;
end;
for i:=0 to 1 do
for j:=0 to 7 do
for k:=0 to 1 do
for n:=0 to 7 do
if (dot_old_buff[i*16+j*2+k]shr (7-n)) and 1 <> 0 then
dot_new_buff[k*16+i*8+n]:= dot_new_buff[k*16+i*8+n] or ($80 shr (7-j));
SetLength(DataBuf[ptr], 32);
move(dot_new_buff, DataBuf[ptr], 32);
inc(ptr, 1);
inc(len, 2);
end
else
begin
off := byte(s[len]) * 16;
for i:=0 to 15 do
begin
dot_asc_old := pasc[off+i];;
dot_asc_new :=0;
end;
for i:=0 to 1 do
for j:=0 to 7 do
for n:=0 to 7 do
if (dot_asc_old[i*8+j]shr (7-n)) and 1 <> 0 then
dot_asc_new[i*8+n]:= dot_asc_new[i*8+n] or ($80 shr (7-j));
SetLength(DataBuf[ptr], 16);
move(dot_asc_new, DataBuf[ptr], 16);
inc(ptr, 1);
inc(len, 1);
end;
end;
converttopos;
end;
procedure TForm1.ConvertToPos;
var i,j:integer;
temp:string;
begin
showmessage(inttostr(high(databuf)));
for i:= low(DataBuf) to High(DataBuf) do
begin
for j:=low(DataBuf) to high(databuf) do begin
temp:=temp+inttohex(ord(DataBuf[i,j]),3)+'H,';
if ((j<>0) and (j mod 8 = 0)) then
temp:=temp+char(13)+char(10);
showmessage('in');
end;
temp := temp + char(13) + char(10);
end;
showmessage(temp);
end;
 
哦,忘记了,其中DATABUF定义为:array of array of byte
 
请大家帮帮忙呀,很急呀, 运行到converttToPos 时就出错了,是不是分配给DATABUF的内存被收回了呀
 
procedure TForm1.CreateData;
var s:string;
off:integer;
len,i,j,k,n,ptr:integer;
dot_old_buff,dot_new_buff : array [0..31] of byte;
dot_asc_old, dot_asc_new : array [0..15] of byte;
//ascstr:string;
//temp,tmp:string;
begin
s := Edit1.Text;
SetLength(DataBuf, Length(Edit1.Text));
StrList.Clear;
len:=1;
ptr := 0;
While len<= Length(s) do
begin
if ((ord(s[len])> 127) and boolean(byte(s[len+1]) and $80)) then
begin
off:=((byte(s[len])-$a1) and $7f) * 94 + ((byte(s[len+1])-$a1) and $7f);
off :=off*32;
for i := 0 to 31 do
begin
dot_old_buff := Byte('A');//phzk[off+i];
dot_new_buff := 0;
end;
for i:=0 to 1 do
for j:=0 to 7 do
for k:=0 to 1 do
for n:=0 to 7 do
if (dot_old_buff[i*16+j*2+k]shr (7-n)) and 1 <> 0 then
dot_new_buff[k*16+i*8+n]:= dot_new_buff[k*16+i*8+n] or ($80 shr (7-j));
SetLength(DataBuf[ptr], 32);
move(dot_new_buff[0], DataBuf[ptr][0], 32);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
inc(ptr, 1);
inc(len, 2);
end
else
begin
off := byte(s[len]) * 16;
for i:=0 to 15 do
begin
dot_asc_old := Byte('B');//pasc[off+i];;
dot_asc_new :=0;
end;
for i:=0 to 1 do
for j:=0 to 7 do
for n:=0 to 7 do
if (dot_asc_old[i*8+j]shr (7-n)) and 1 <> 0 then
dot_asc_new[i*8+n]:= dot_asc_new[i*8+n] or ($80 shr (7-j));
SetLength(DataBuf[ptr], 16);
move(dot_asc_new[0], DataBuf[ptr][0], 16);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
inc(ptr, 1);
inc(len, 1);
end;
end;
converttopos;
end;
 
接受答案了.
 

Similar threads

I
回复
0
查看
588
import
I
I
回复
0
查看
644
import
I
后退
顶部