Most of the time when I want to nest conditional OMITs and/or COMPILES it works as desired.
However sometimes the compiler complains about it.
Note: you do have to be careful to make sure that the 1st argument (the terminator string), is NOT a substring of an another OMIT/COMPILE
The HELP for OMIT says
The compiler reads and parses source/include files by blocks. If the end of an OMIT/COMPILE block (terminator string) is found in the current block, the compiler either with skip the text up to terminator or will continue to parse the file - depending on whether you are using OMIT or COMPILE and what condition. If the terminator string is found within the current block and parsing is continuing, nested OMIT/COMPILE statements are allowed. If the terminator string is not found, nested OMIT/COMPILE statement in this block is not allowed.
In summary, nesting of OMIT/COMPILE statements is dependent on the current compiler block. Use of conditions in OMIT/COMPILE statements and possibility to define complex conditions as EQUATEs are allowed to avoid excessive nesting of OMIT/COMPILE statements.
So what is a block of code?
To me this means that the compiler reads X bytes of code at a time from your source
I’m not sure what the value is for X - it’s probably a “round number” like 4K, 8K, or 16K
But I guess it doesn’t really matter.
So today I tried something new when I hit “Omit cannot be nested” problem
I added a comments above the code where I was nesting omits
to move the nesting omit/compiles to another block of code.
I still had the error when I compiled
So I added more comments, and compiled again
and kept repeating the process until I got a clean compile.
In this case, I added about 2500 characters in the comments