procedure TForm1.DateTimePicker1Change(Sender: TObject);
begin
  RichEdit1.Lines.Clear;
  Table1.Active:=false;
  Table1.TableName:='日记表.DB';
  Table1.Active:=true;
  with Table1 do
  begin
    SetKey;
    FieldByName('日期').AsString:=DateToStr(DateTimePicker1.Date);
    if GotoKey then
    begin
      diarypath:=FieldByName('路径').AsString;
      AssignFile(f2,diarypath);
      Reset(f2);
      while not eof(f2) do   //编译器提示出错地方
        begin
          readln(f2,bufferStr);
          RichEdit1.Lines.Add(bufferStr);
        end;
      CloseFile(f2);
    end;
  end;
end;
此段代码的作用为:在DateTimePicker组件里面选择日期,提取所选日期在数据库的'日记表'中查找当天日记的系统路径,然后利用路径进行文件读取操作,将日记内容显示于RichEdit组件中.读取文件时判断文件是否末尾用EOF(F1),否则读取文件一行内容写入RichEdit.
结果编译器报错,提示错误如下:
[Error] Unit1.pas(656): Missing operator or semicolon
[Fatal Error] Project2.dpr(6): Could not compile used unit 'Unit1.pas'
小弟愚钝,未能解决错误,各位大虾指教~

解决方案 »

  1.   

    Missing operator or semicolon
    一般是少了个分号
      

  2.   

    注意with Table1 do
    table对象也有eof函数,它是被优先使用的
    你要用system.eof(f2)才能调用文件函数eof少用with
      

  3.   

    晕。。光看[Error] Unit1.pas(656): Missing operator or semicolon
    [Fatal Error] Project2.dpr(6): Could not compile used unit 'Unit1.pas'
    这些了。。没看代码。。with有好处,也有坏处,嵌套使用的时候,要注意。
      

  4.   

    真的很感谢ysai大虾,还有大家谢谢你们的提醒!!