Dataset loop condition never met

Very often a loop is used to go through all the records in a dataset using Next (or Prior) to go to a different record and checking the end of file marker EOF (or BOF) to see if the loop is finished. However, if the ‘Next’ or ‘Prior’ statement is omitted, the loop might never finish.

For example:

  while not (qry.EOF) do begin
    //Processing
    //...
  end;

Solution:

  while not (qry.EOF) do begin
    //Processing
    //...
    qry.Next; //eyebol warns if this is not found
  end;




< Back to list of hints and warnings