自定义数据结构数组运算出错?(100分)

  • 主题发起人 主题发起人 oldzhang
  • 开始时间 开始时间
O

oldzhang

Unregistered / Unconfirmed
GUEST, unregistred user!
自定义结构如下:
TPokerNum = Array[0..15] of byte;
TPlayer=record
id,name:string;
send,save:TPokerNum;
curr:0..36;
detail:Array[1..36] of byte;
end;
var
Player:Array[0..5] of TPlayer;
通过以下的运算:
with Player do
begin
send[0]:=send[0]+1;
send[pokerid]:=send[pokerid]+1;
curr:=curr+k;
detail[curr]:=poker;
end;
数据出现异常,暂停程序,通过Watch、EVaulate查看数据,发现无法访问到Player[1]、Player[2]、Player[5]数据,请问这是哪里的问题?是数据结构本身定义的有问题,还是用法有问题
 
with Player do // i這個值要在..5間
begin
send[0]:=send[0]+1;;
send[pokerid]:=send[pokerid]+1
// curr這個值要在1..36間
curr:=curr+k;
detail[curr]:=poker;
end;
 
数据结构是没问题的
关键在于要注意不能超出所定义的边界
你代码不全,比如pokerid于i的初值等问题;
最好查看下有没有超出所定义的边界
 
多帖点代码,看不明白
 
问题没有解决,贴出函数代码大家帮我看看。
TBigBuf=array[0..2048] of byte;
TPokerNum = Array[0..15] of byte;
PData = ^TData;
TData = record
Hook: THandle;
Hooked: Boolean;
BufByte:TBigBuf;
BufLen:integer;
end;
TPlayer=record
id,name:string;
send,save:TPokerNum;
curr:0..PlayCards;
detail:Array[1..PlayCards] of byte;
end;
var
DllData:PData;
MapHandle:THandle;
Player:Array[0..5] of TPlayer;
AllSend:TPokerNum;
Procedure TMainForm.RecordCard;
var
i,j,k,poker,pokerid:byte;
begin
i:=DllData^.BufByte[1];
j:=DllData^.BufByte[3];
for k:=1 to j do
begin
poker:=DllData^.BufByte[3+k];
if (poker>=4) and (poker<=57) then
begin
if poker=57 then
pokerid:=15
else
pokerid:=poker div 4;
with Player do
begin
send[0]:=send[0]+1;
send[pokerid]:=send[pokerid]+1;
curr:=curr+k;
detail[curr]:=poker;
end;
AllSend[0]:=AllSend[0]+1;
AllSend[pokerid]:=AllSend[pokerid]+1;
end;
end;
end;
 
问题解决,确实是curr越界
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
后退
顶部