Chapter 7. Control Structures

Table of Contents

if
while
do...while
for
break
continue
return
Compound Statements

Inside <% %> tags RSP code consists of a sequence of sequentially executed statements. These may be expressions, variable declarations, function declarations or control statements.

This chapter will describe the control statements in RSP. Control statements are used to affect the flow of execution in your programs.

if

The if statement is used to conditionally specify which branch the program should take. The syntax is shown below.

Example 7.1. if statement syntax

if(/* boolean expression */)
    // Statement
else
    // Statement

The else clause is optional. It is common to use an if statement as the statement in the else clause as shown below:

Example 7.2. if...else statement syntax

if(/* boolean expression */)
    // Statement
else if(/* boolean expression */)
    // Statement
else if(/* boolean expression */)
    // Statement
else
    // Statement