Ian Branch 127 Posted January 11 Hi Team, Using D12. It may be my missunderstanding but.. I have the following code: Suppliers.First; // while not Suppliers.eof do begin // sSelected := Suppliers.FieldByName('SupplierCode').AsString; sDescription := Suppliers.FieldByName('SupplName').AsString; // Parts.Close; Parts.SQL.Clear; Parts.SQL.Text := 'Select * from Parts where SupplierCode = ' + quotedStr(sSelected) + ' and BusCode = ' + QuotedStr(sBusCode); Parts.Prepare; Parts.Open; // if Parts.eof then begin // TaskMessageDlg('No parts available!', 'There are no Parts on record for Supplier - ' + sDescription + ' at location ' + sLocation + '.', // mtInformation, [mbOK], 0) Label1.Caption := 'There are no Parts on record for Supplier - ' + sDescription + ' at location ' + sLocation + '.'; // Suppliers.Next; // Continue; // end else begin // Omitting the Suppliers.Next for the moment, I allways thought that a Continue would have automatically caused Suppliers to move to the next record by virtue of the 'while not Suppliers.eof do'. In my case of the code above, it doesn't, I had to insert the Suppliers.Next; line. Was my understand incorrect or is there some other explanation? Regards & TIA, Ian Share this post Link to post
Stano 143 Posted January 11 https://docwiki.embarcadero.com/RADStudio/Athens/en/Continue Share this post Link to post
Ian Branch 127 Posted January 11 (edited) Hi Stano, Tks for the reference. OK, so it doesn't cause the step. I need to review a few other pieces of code. 😞 Rightly or wrongly, I have always worked on it stepping. Edited January 11 by Ian Branch Share this post Link to post
Stano 143 Posted January 11 I'm avoiding the Continue command. I use it exceptionally. en when I need to skip/skip something. At least that's how I understand it. So I usually have it in some if..then..else... branch. In the above example it has no meaning. I suppose this is just a symbolic demonstration. Share this post Link to post
Remy Lebeau 1394 Posted January 11 (edited) On 1/11/2024 at 10:19 AM, Ian Branch said: I allways thought that a Continue would have automatically caused Suppliers to move to the next record by virtue of the 'while not Suppliers.eof do'. Nope. Eof simply evaluates the current record, it does not move to another record. Hence the need to call Next() explicitly. On 1/11/2024 at 10:19 AM, Ian Branch said: Was my understand incorrect Yes. Edited January 12 by Remy Lebeau 1 Share this post Link to post
Ian Branch 127 Posted January 11 Thanks Guys, It's surprising I have operated under this missunderstanding for so long.... 😞 All good now. Again, thank you. Regards, Ian Share this post Link to post
Uwe Raabe 2057 Posted January 11 57 minutes ago, Remy Lebeau said: If you want the loop to iterate through the records automatically, use a for..in loop instead, see Iteration Over Datasets Using For Statements, for example: Did you actually try that? Even in Delphi 12 this report is still valid: https://quality.embarcadero.com/browse/RSP-39614 Share this post Link to post
Remy Lebeau 1394 Posted January 11 (edited) 36 minutes ago, Uwe Raabe said: Did you actually try that? No. I just knew the feature supposedly exists. Quote Even in Delphi 12 this report is still valid: https://quality.embarcadero.com/browse/RSP-39614 Ouch! And not even opened for review yet.... Edited January 11 by Remy Lebeau 1 Share this post Link to post
Uwe Raabe 2057 Posted January 12 It basically one of the rare cases when documentation was updated, but the underlying feature was dropped just before the release for several reasons. So it boils down to just fix the docs. Share this post Link to post
Anders Melander 1782 Posted January 12 2 hours ago, Uwe Raabe said: the underlying feature was dropped And thank Flying Spaghetti Monster for that. What a horrible design. Share this post Link to post
Uwe Raabe 2057 Posted January 12 I know, most likely I'm biased, but I'm not aware of any other working dataset enumerator than this one: https://github.com/UweRaabe/DataSetEnumerator. First described a couple of years ago on my blog: Dataset Enumerator Reloaded and now part of CmonLib. 2 Share this post Link to post