If...Else

<< Click to Display Table of Contents >>

Navigation:  Explain™ Control Language  > Explain™ fundamentals >

If...Else

Description

You can control execution of alternative blocks of statements using the syntax:

 

if (Test)

 Statement1

else

 Statement2

 

The Test is an expression which evaluates to a BOOLEAN value (either TRUE or FALSE). In most cases, Test is a comparison such as (x lt 256).

 

An if can control a block of statements. Indenting shows the scope of the block:

 

if (Test)

 Statement1

 Statement2

 Statement3

Statement4

 

Statements 1, 2, and 3 are under the control of the Test. If the Test is TRUE, all the statements are executed. If it is FALSE, only Statement4 is executed.

 

You can extend the syntax using the else if keyword:

 

if (Test1)

 Statement1

else if (Test2)

 Statement2

else

 Statement3

 

Related Topics