代码出错,请高手分析解答原因 ( 积分: 100 )

  • 主题发起人 主题发起人 菜鸟阿胡
  • 开始时间 开始时间

菜鸟阿胡

Unregistered / Unconfirmed
GUEST, unregistred user!
[?]
代码如下:
procedure loadmulu;
var i,j:integer;
begin
if fileexists('mulu.dat') then
begin
reset(mulufile);
while not eof(mulufile) do
begin
read(mulufile,mulu0);
form1.ComboBox1.Items.Add(mulu0.name);
end;
seek(mulufile,0);
read(mulufile,mulu0);
form1.ListBox1.Items.Add(mulu0.name);
end else
rewrite(mulufile);
closefile(mulufile);
end;

procedure TForm2.btaddokClick(Sender: TObject);
var i0,j0:integer;
change:boolean;
temp:string;
begin
if combobox1.ItemIndex=-1 then
begin
seeker:=-1;
reset(mulufile);
repeat
inc(seeker);
seek(mulufile,seeker);
until eof(mulufile);
temp:=combobox1.Text;
mulu0.name:=temp;
mulu0.items.Clear;
mulu0.items.Add(edit1.Text);
write(mulufile,mulu0);
loadmulu;
temp:='dai'+inttostr(filesize(mulufile))+'.dat';
closefile(mulufile);
assignfile(daifile,temp);
rewrite(daifile);
dai0.name:=edit1.Text;
dai0.items:=memo1.Lines;
write(daifile);
closefile(daifile);
loadmulu;
end;
代码出错信息如下:
projct project1.exe raised exception class eaccessviolatio
with message 'access violation at address 004656c3 in module'
project1.exe'.read of address 00000000'.process stopped.
ues step or run to continue.
 
[?]
代码如下:
procedure loadmulu;
var i,j:integer;
begin
if fileexists('mulu.dat') then
begin
reset(mulufile);
while not eof(mulufile) do
begin
read(mulufile,mulu0);
form1.ComboBox1.Items.Add(mulu0.name);
end;
seek(mulufile,0);
read(mulufile,mulu0);
form1.ListBox1.Items.Add(mulu0.name);
end else
rewrite(mulufile);
closefile(mulufile);
end;

procedure TForm2.btaddokClick(Sender: TObject);
var i0,j0:integer;
change:boolean;
temp:string;
begin
if combobox1.ItemIndex=-1 then
begin
seeker:=-1;
reset(mulufile);
repeat
inc(seeker);
seek(mulufile,seeker);
until eof(mulufile);
temp:=combobox1.Text;
mulu0.name:=temp;
mulu0.items.Clear;
mulu0.items.Add(edit1.Text);
write(mulufile,mulu0);
loadmulu;
temp:='dai'+inttostr(filesize(mulufile))+'.dat';
closefile(mulufile);
assignfile(daifile,temp);
rewrite(daifile);
dai0.name:=edit1.Text;
dai0.items:=memo1.Lines;
write(daifile);
closefile(daifile);
loadmulu;
end;
代码出错信息如下:
projct project1.exe raised exception class eaccessviolatio
with message 'access violation at address 004656c3 in module'
project1.exe'.read of address 00000000'.process stopped.
ues step or run to continue.
 
指针错误,你的代码不全,很难看出来
 
帮顶

--------签名档---------------------------

惊爆开源站

http://www.source520.com

80G源码电子书免费免注册下载,大量精辟技术文档库随时更新
 
后退
顶部