General:.
:if (test){arg[.fl]{code}}
:elseif (test){arg[.fl]{code}}
:else {arg[.fl]{code}}
Above you see the general form of the :if/ :elseif / :else structure.
The italicized portions are optional. :if makes a test to decide if
its block should be executed. If the test returns anything non-zero or false,
the block is ignored and the next test in the form of an :elseif or
:else is tried. The :else block can be used if all tests
fail. The :if must be the first control token. If there is an
:else it must be the last control token. There can be any number of
intervening :elseif tokens. If a test passes, its block is executed
and the structure is exited ignoring all other blocks. If all tests fail and
there is no catchall :else, the structure exits. The result is from
whichever block gets executed. If that blocks ends with a semicolon or if no
blocks get executed, the result is NULL.
Simple if/elseif/else: This is
a little expert system that tells you what to do when coming onto a traffic
light. We use a vector to light states and a :for loop to test all
possible cases of our little system.