Jump to content
Ian Branch

Help with 'Continue' pls.

Recommended Posts

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

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 by Ian Branch

Share this post


Link to post

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
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 by Remy Lebeau
  • Like 1

Share this post


Link to post

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

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×