IF..THEN..ELSE

6.4 IF..THEN..ELSE

Another fundamental part of programming logic is the ability to offer a choice of what to do that depends on the conditions asked of. (I'm not sure that makes any sense...). The format is:

IF {identifier-1} {condition} {identifier-2 or literal} ...
THEN {statements}
[ELSE {statements}]
END-IF

An example:

      IF X = Y THEN
         MOVE 1 TO Y-COUNTER
      ELSE
         MOVE 1 TO X-COUNTER
      END-IF


ELSE is used if an alternative statement is to be executed if the first condition is false. If there was only to be action if X = Y then the ELSE would be ommitted.

The END-IF terminates the IF statement. All that lies between IF and END-IF will depend on the conditions being tested.

Multiple conditions can be tested, i.e. IF (X = Y) AND (Y The types of conditions available are described in the following section..