谁能给我指点解决错误的办法啊??/
type
test=record
id:string[10];
name:string[10];
end;
var 
data:test;
datafile:file of test;
procedure tform1.button1click(....);
begin
assignfile(datafile,'g:\test\1.text');
filemod:=2;
reset(datafile);//出错*****他说我的文件名变量datafile无效********
seek(datafile,filepos(datafile));
data.id:=edit1.text;
data.name:=edit2.text;
write(datafile,data);
closefile(datafile);
end;

解决方案 »

  1.   

    procedure Reset(var F [: File; RecSize: Word ] );DescriptionReset opens the existing external file with the name assigned to F using the mode specified by the global FileMode variable. An error results if no existing external file of the given name exists or if the file can抰 be opened with the current file mode. If F is already open, it is first closed and then reopened. The current file position is set to the beginning of the file.
    因为你的1.text文件不存在的原因,你要先建立这个文件才可以
      

  2.   

    reset只可以打开存在的文件
    你只需要加上
    if not fileexists('1.txt') then
        rewrite(datafile);
    就可以了
    呵呵~~~