in Delphi for Beginners :: In Delphi, the if statement is used to test for a condition and then execute sections of code based on whether that condition is True or False. Watchout for If Then Else traps if you are a beginner using nested if statements.
Read the full article to learn about The Traps of The If Then Else Statement in Delphi Code
Related:

Just use a semicolon and it looks a lot better.
if j >= 0 then
if j = 100 then Caption := ‘Number is 100!’ else ;
else
Caption := ‘Number is NEGATIVE!’;
@Andreaa
You may think it looks better, but it can’t compile as the semicolon refers to the *outermost* IF statement, so the second ELSE clause is now illegal.
better to use:
if (…) then
if (…) then (…)
else begin end
else (…);
Wathch for the begin-end pair without any contents!
Another option is to use one begin-end pair without contents:
if (…) then
if (…) then (…)
else begin end
else (…);
It should be this.
if (j >= 0)
then begin
if (j = 100)
then Caption := ‘Number is 100!’;
end
else Caption := ‘Number is NEGATIVE!’;
The above code is not showing my indentation. The second If Then End should line up with the first Begin
Hoping one day all block statements in a language will have a simple end mechanic without having to begin/end or squiggly:
if x > 0 then
blah;
blah;
else
foo;
foo;
end;