Using Continue in a While Loop

Is it possible to use Continue in a While loop when working with text files?

I would like to do some processing and check some values. If true, I would like to skip the iteration. If false, I would like to continue the next set of lines (continue processing).

while not EOF(InFile) do  
begin  
 DoSomething;  
 if (AcctTag = '') OR (MasterId = '') then  
  Continue;  
 DoSomething;  
end;  

Does it continue to skip the iteration in this case?

+5
source share
2 answers

The test is not even needed. The documentation already tells you the answer:

In Delphi code, the Continue procedure causes the control flow to proceed to the next iteration of the application to include, while or repeat.

, , . Continue . , Eof , .

+7

, 30- , .:)

program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  i, j: Integer;

begin
  j := 0;
  i := 0;
  while i < 10 do
  begin
    Inc(i);
    if Odd(i) then
      Continue;
    Inc(j);
    WriteLn(Format('i = %d, j = %d', [i, j]));
  end;
  ReadLn;
end.

Sample output

, i Continue, , j , even? j , Continue.

A while , , . A while while while , . , DoSomething , .

+12

All Articles