Page 1 of 1

EOF / BOF not really End / Start

Posted: 04.04.2016, 17:09
by IbeDBob
I am doing some updates on some old D5 stuff with SQLite3 so have to use Zeos 6.

This is not working as expected.
..Click Next until the Last File is in use.
....Click Next again and it displays the Last File again. // Surely it should have be at the last File after the Last Next??
......Click Next and then it will go to the First File in the DB.

Code: Select all

procedure TfrmMain.btnNextClick(Sender: TObject);
begin
  if dm.tblFiles.EOF then
    dm.tblFiles.First else
    dm.tblFiles.Next;
end;
Is it me or is this the correct behavior?
It works similarly for the Prior button too.
How do I remove the need for that second click at the end?

Re: EOF / BOF not really End / Start

Posted: 04.04.2016, 21:22
by marsupilami
Hello Bob,

this is really Delphi stuff. EOF is only set if you try to browse behind the last record. So your procedure should look something like this:

Code: Select all

procedure TfrmMain.btnNextClick(Sender: TObject);
begin
  dm.tblFiles.Next;
  if dm.tblFiles.EOF then
    dm.tblFiles.First;
end;
Best regards,

Jan

Re: EOF / BOF not really End / Start

Posted: 06.04.2016, 00:15
by IbeDBob
Awesome, thanks. Had not thought of trying that, must be getting older than I thought. :)

Re: EOF / BOF not really End / Start

Posted: 07.04.2016, 15:42
by marsupilami
Naah - everybody has moments where one just doesn't see the easy and obvious solution. I had it too... ;)