Nested IF statements

When an IF statement appears as statement-1 or statement-2, or as part of statement-1 or statement-2, that IF statement is nested.

When an IF statement appears as statement-1 or statement-2, or as part of statement-1 or statement-2, that IF statement is nested.

Nested IF statements are considered to be matched IF, ELSE, and END-IF combinations proceeding from left to right. Thus, any ELSE encountered is matched with the nearest preceding IF that either has not been already matched with an ELSE or has not been implicitly or explicitly terminated. Any END-IF encountered is matched with the nearest preceding IF that has not been implicitly or explicitly terminated.