Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread Table.Bof and Eof don't behave the same
Tue, May 24 2016 8:41 AMPermanent Link

Rolf Frei

eicom GmbH

To loop a table for all records we can use this:

table.First;
while not table.Eof do
 // do something
 table.Next;
end;

This works a expected.

Now I must to the same but in reverse order. So I use this:

table.Last;
while not table.Bof do
 // do something
 table.Prior;
end;

This does not catch the last (first) record in the table. As soon the cursor is moved to the first record with Prior, Bof is true, which is wrong. It should get true only if we move the cursor to the prior not existing record as it is on the Eof call.

Is this a EDB or a TDataset bug (XE4)?
Tue, May 24 2016 9:06 AMPermanent Link

Rolf Frei

eicom GmbH

Ouch!!! This was my fault. Everything seems to work correct.

I used a Filter and did change the filter field value in the loop. This will remove the record from the filter and automaticly moves to the next record. So an additonal Prior would give a Bof as it is already on the first record.
Tue, May 24 2016 9:51 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Rolf


Welcome to the club - the number of times I've done that (or the equivalent of deleting rows as you go) - great fun. Almost as much fun as forgetting the .Next!
Roy Lambert
Image