I just wanted to show the "nesting" problem.
Let's see some other case.
for i := 0 to N do beign
if cond1 then begin
State := 1;
Var1 := afunction(state);
end
else begin
// do something;
if cond2 then begin
State := 2;
Var2 := afunction(state);
end
else begin
// Do others
if cond3 then begin
State := 3;
Var1 := anotherfunction(State);
Var2 := afunction(State3);
end
else begin
// Do more things
end
end
end
end;
We can write this as:
for i := 0 to N do beign
if cond1 then begin
State := 1;
Var1 := afunction(state);
Continue;
end ;
// do something;
if cond2 then begin
State := 2;
Var2 := afunction(state);
Continue;
end ;
// Do others
if cond3 then begin
State := 3;
Var1 := anotherfunction(State);
Var2 := afunction(State);
Continue;
end;
// Do more things
end;
And think of cases where are rather lot of codes in the commented part of "do something", "do others", etc. The same with Exit.