类型文件错误(100分)

W

wzpok

Unregistered / Unconfirmed
GUEST, unregistred user!
我程序中用到类型文件可读取时总是出现EINOUTERROR“io错误103”这样的提示?我是新手
总是找不到原因?恳请各位大虾相助!
 
103 错误的意思是:文件没有打开
再度文件之前需要
assign(f, fileName)
//注意要用绝对或者相对路径
reset(f);
 
看看源代码片段才能回答.
 
这是程序片段
procedure usefile
{使用当前设置时间}
var
altimerh,inh,inm:integer;
finalfile:file of final;
altimer,hour:string;
timenow:tdatetime;
begin

if weekend then
begin
altimerh:=0;
altimer:='';
seek(finalfile,0);
read(finalfile,finaldata);
if finaldata.start then
form1.CheckBox1.Checked:=true;{若已添加在启动则选中单选钮}
correcttimer(altimerh,altimer);
if altimerh<10 then
hour:='0'+ inttostr( altimerh)
else
hour:= inttostr( altimerh);
tmal:= hour+':'+altimer
tmcl:=finaldata.final1+':'+ finaldata.final2;
end

else
begin
seek(finalfile,1);
read(finalfile,finaldata);
if finaldata.start then
form1.CheckBox1.Checked:=true;
correcttimer(altimerh,altimer);
if altimerh<10 then
hour:='0'+ inttostr( altimerh)
else
hour:= inttostr( altimerh);
tmal:= hour+':'+altimer
tmcl:=finaldata.final1+':'+ finaldata.final2;

end;
timenow:=now;
inh:= strtoint(hour)-strtoint(formatdatetime('hh',timenow));
inm:= strtoint(altimer)-strtoint( formatdatetime('nn',timenow));
form1.timer1.interval:= inh*60*60*1000+inm*60*1000;
end;
assignfile(finalfile,fname);
//
reset(finalfile);
usefile;{使用前函数};
 
兄弟我对你提一点建议好吗?

编写代码规范一点,这样好看,我这里有一篇关与编码规范的文章

(就是程序员大本营中的那一篇)如有兴趣我MAIL给你

BUDDYWANG@263.NET
 
i see.
问题在finalfile定义的位置不对.
如果你最后3句代码在procedure usefile里(递归调用), 那么运行usefile时file还没打开

如果最后3句是主程序的, 那么var finalfile定义在usefile里, 主程序看不到的. 调用时
finalfile仍然是未定义的(也是没有打开的).
 
到那里可已找到有关103错误等类似提示的全部介绍 若有给我一个!

wzpok@990.net
 
Delphi 的帮助里面全部都有:
这样赵:
Index->I/O errors
 

Similar threads

回复
0
查看
854
不得闲
回复
0
查看
810
不得闲
回复
0
查看
677
不得闲
顶部