11.29 if

if <criterion> <code>
{ else if <criterion> <code> }
[ else                <code> ]

The if command allows conditional execution of blocks of commands. The code enclosed in braces following the if statement is executed if, and only if, the criterion is satisfied. An arbitrary number of subsequent else if statements can optionally follow the initial if statement; these have their own criteria for execution which are only considered if all of the previous criteria have tested false – i.e. if none of the previous command blocks have been executed. A final optional else statement can be provided; the block of commands which follows it are executed only if none of the preceding criteria have tested true. The following example illustrates a chain of else if clauses:

if (x==2)
  print "x is two!"
 } else if (x==3) {
  print "x is three!"
 } else if (x>3) {
  print "x is greater than three!"
 } else {
  print "x didn't used to be two, but it is now!"