| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
As part of the if ... then ... else statement:
if Boolean expression then statement1 else statement2 |
case ... else statement:
case expression of selector: statement; ... selector: statement else statement; ... statement end |
`else' is part of the `if ... then ... else' statement
which provides a possibility to execute statements alternatively. In
the case statement, `else' starts a series of statements
which is executed if no selector fit in expression. In this case,
`else' is a synonym for otherwise.
`else' in `if' statements is defined in ISO-7185 Pascal and supported by all known Pascal variants. `else' in `case' statements is a Borland Pascal extension; ISO-10206 Extended Pascal has `otherwise' instead.
program ElseDemo;
var
i: Integer;
begin
Write ('Enter a number: ');
ReadLn (i);
if i > 42 then
WriteLn ('The number is greater than 42')
else
WriteLn ('The number is not greater than 42')
end.
|
section 9.110 if, section 9.38 case, section 9.184 otherwise.