Continue
次の反復に進むために使用します。finally
ブロックの部分のコードはtry..finally
常に実行されるように設計されているため、強制的に次の反復にスキップしても:
procedure TForm1.Button1Click(Sender: TObject);
begin
repeat
TryAgain := False;
try
if SomeCondition then
begin
TryAgain := True;
// this will proceed the finally block and go back to repeat
Continue;
end;
// code which would be here will execute only if SomeCondition
// is False, because calling Continue will skip it
finally
// code in this block is executed always
end;
until
not TryAgain;
end;
しかし、まったく同じロジックを次のように簡単に書くことができます:
procedure TForm1.Button1Click(Sender: TObject);
begin
repeat
TryAgain := False;
try
if SomeCondition then
begin
TryAgain := True;
end
else
begin
// code which would be here will execute only if SomeCondition
// is False
end;
finally
// code in this block is executed always
end;
until
not TryAgain;
end;