13.38 IF Statement
The IF
statement either runs or skips a sequence of one or more statements, depending on the value of a BOOLEAN
expression.
Topics
Syntax
if_statement ::=
Semantics
boolean_expression
Expression whose value is TRUE
, FALSE
, or NULL
.
The first boolean_expression
is always evaluated. Each other boolean_expression
is evaluated only if the values of the preceding expressions are FALSE
.
If a boolean_expression
is evaluated and its value is TRUE
, the statements after the corresponding THEN
run. The succeeding expressions are not evaluated, and the statements associated with them do not run.
ELSE
If no boolean_expression
has the value TRUE
, the statements after ELSE
run.
Examples
-
Example 4-1, "IF THEN Statement"
-
Example 4-2, "IF THEN ELSE Statement"
-
Example 4-3, "Nested IF THEN ELSE Statements"
-
Example 4-4, "IF THEN ELSIF Statement"
Related Topics
In this chapter:
In other chapters: