The else-if Construct

There are times when one must create a multi-way conditional depending on several different conditions. One way to do this is to use nested 'if statements, that is, place a second 'if statement in the 'else part of the first statement. This relatively common construct can be expressed more compactly using the 'elif statement. For example, suppose you want to generate three different types of statement, depending on whether the variable 'x has the value 1, 2 or 3. The following sequence of statements will accomplish this.

'if 'x'==1
and (a,b),c
'elif 'x'==2
or (a,b),c
'elif 'x=3
xor (a,b),c
'else
'error s,"Invalid value of x"
'endif

Note that a single 'endif statement is used to terminate the 'if construct. The 'else portion of the statement will be executed if none of the preceding conditions are true. The body of an 'elif portion will be executed if the corresponding condition is true and all preceding conditions are false. The 'elif statement has a single operand which follows the same rules as the operand of the 'if statement.