Subject Re: [IBO] EOF BOF craziness
Author Paul Vinkenoog
Hi Daniel,

>> b) Turn off Eof and go to the last-but-one record? Also logical,
>> because after all Prior means "go back one record".
>
> That is TDataset's behavior.
>
> Here's the behavior of TDataset.EOF, taken from Delphi's help and
> TDataset is not the BDE:

You're right, I should have said: the TDataset hierarchy. But Paul
lured me into it! :-) (The other Paul, that is.)

> "Test Eof (end-of-file) to determine if the active record in a dataset
> is the last record. If Eof is True, the current record is
> unequivocally the last row in the dataset. Eof is True when an
> application:
>
> - Opens an empty dataset.
> - Calls a datasetÂ’s Last method. (Unless it is a unidirectional
> dataset)
> - Call a datasetÂ’s Next method, and the method fails because the
> current record is already the last row in the dataset.
> - Calls SetRange on an empty range or dataset.
>
> Eof is False in all other cases.
>
> Tip: If both Eof and Bof are True, the dataset or range is empty."
>
> And, the equivalent can be said for the BOF property.

Thanks for the information. Actually, it was a bit lazy of me to ask
the question, because I could have looked it up too...

Still, these helptexts leave some questions open. For instance: if Eof
is true when you are on the last record, and Bof when you are on the
first, Eof and Bof should both be true when you are on the only record
of a singleton set. But if that were the case, you couldn't use the
"Bof and Eof" condition to test for an empty set.

However, after reading the helptext carefully, especially the line
"Eof is false in all other cases", Eof must be:

- FALSE if you arrive on the last record after a Next, but
- TRUE if you get there with a Last

I think this is _very_ confusing. And it also means that you can't use
Eof to test if you are on the last record. Yes, if Eof is true you are
definitely on the last record (or in an empty set), but the reverse
isn't necessarily true: if you are on the last record, Eof may or may
not be true. Thus, the first sentence of the help text is misleading.

To me, the IBO way is much, much cleaner and more consistent.


Greetings,
Paul Vinkenoog