Nested IF-THEN-ELSE-END IF

The THEN part and the ELSE part, if any, can contain one or more IF-THEN-ELSE-END IF statement in one of the three forms. That is, when you feel it is necessary, you can use as many IF-THEN-ELSE-END IF statements in the THEN part and the ELSE part as you want. However, please note that any such IF-THEN-ELSE-END IF must be fully contained in the THEN part or the ELSE part. If you follow the box trick, this requirement is automatically satisfied. The following is an example:

IF (logical-expression) THEN
   statements
   IF (logical-expression) THEN
      statements
   ELSE
      statements
   END IF
   statements
ELSE
   statements
   IF (logical-expression) THEN
      statements
   END IF
   statements
END IF

Examples