COBOL Manual for TNS/E Programs (H06.08+, J06.03+)
Example 155 Nested IF and IFNOT Directive Scopes
IF and IFNOT scopes can be nested. Given this program fragment:
01 MASTER-RECORD.
03 HEADER PICTURE X(30).
?IF 1
03 ACCOUNT-ID PICTURE X(50).
?IF 2
03 ACCOUNT-ID-REDEF REDEFINES ACCOUNT-ID.
05 ACCOUNT-GROUP PICTURE X(20).
05 ACCOUNT-CLASS PICTURE X(10).
05 ACCOUNT-NUMBER PICTURE X(20).
?ENDIF 2
03 TRAILER PICTURE X(100).
?ENDIF 1
The compiler sees this, depending on the setting of toggles 1 and 2:
Toggles On Source Lines Compiled
None 01 MASTER-RECORD.
03 HEADER PICTURE X(30).
1 only 01 MASTER-RECORD.
03 HEADER PICTURE X(30).
03 ACCOUNT-ID PICTURE X(50.
03 TRAILER PICTURE X(100).
2 only 01 MASTER-RECORD.
03 HEADER PICTURE X(30).
1 and 2 01 MASTER-RECORD.
03 HEADER PICTURE X(30).
03 ACCOUNT-ID PICTURE X(50).
03 ACCOUNT-ID-REDEF REDEFINES ACCOUNT-ID.
05 ACCOUNT-GROUP PICTURE X(20).
05 ACCOUNT-CLASS PICTURE X(10).
05 ACCOUNT-NUMBER PICTURE X(100).
03 TRAILER PICTURE X(100).
Lines whose compilation IF or IFNOT suppresses still appear in the compiler listing. To keep them
from appearing, use NOLIST and LIST directives as the code fragments in Example 156 show.
554 Program Compilation










