Exit from an "if" in Delphi

Viewed 11846

you can exit a while loop with break.

How to exit from an if .

Is there a kind of GOTO in Delphi ?

procedure ...
begin

  if .... then
    begin

      here the code to execute

      if (I want to exit = TRUE) then
        break or GOTO

      here the code not to execute if has exited

    end;

  here the code to execute

end;
9 Answers

readeable code

// if cond1 then if cond2 then if cond3 then -

procedure cond1_cond3;
begin

  if 
   not(Cond1) then exit;

cond1_work;

  if 
   not(Cond2) then exit;

cond2_work;

  if 
   not(Cond3) then exit;

cond3_work;


end;

procedure All_Work;

begin
   All_work_1;

   cond1_cond3; 

  All_work_2; 

end
Related