1 if Condition then Statement else Statement;
2 case Expression of
Case clauses
...
else
Statements
end;
3 try
Statements
...
except
Exception statements
...
else
Statements
end
Description
The Else keyword is part of the If, Case and Try statements. It is used to start the section of code executed when earlier conditions are not satisfied.
See details of each of these statements for further details.
Related commands
Case A mechanism for acting upon different values of an Ordinal
End Keyword that terminates statement blocks
If Starts a conditional expression to determine what to do next
Then Part of an if statement - starts the true clause
Try Starts code that has error trapping
Example code : Illustrate various uses of the else clause
begin
// Note the lack of a ';' after the 'then' clause
if False
then ShowMessage('True')
Else ShowMessage('False');
// Nested if statements - Delphi sensibly manages associations
if true then
if false then
ShowMessage('Inner then satisfied')
Else
ShowMessage('Inner else satisfied')
Else
ShowMessage('Outer else satisfied')
end;
Show full unit code
False
Inner else satisfied