Programs are composed of blocks which look and act like units. Most block structures can be nested, which means located inside other blocks. To promote clarity, readability, and visibility of program structure, source lines in block structures should be indented by a tab or two spaces.
Functions are the outermost blocks. Within functions, five block structures are common:
° IF ... END IF
° SELECT CASE ... END SELECT
° DO ... LOOP
° FOR ... NEXT
° SUB ... END SUB
Except for functions and subroutines, blocks can be nested. It is common to find these blocks nested several levels deep in many programs.
Each block must fully enclose all blocks within it. In other words, a block must end before any block in which it is imbedded. This does not mean that execution necessarily proceeds through blocks in the order of the source program. Statements exist to control execution within and between blocks, and for multi-level exits.
The reference section describes statements that control execution in and between blocks, including:
° DO DO
° DO LOOP
° DO FOR
° DO NEXT
° EXIT DO
° EXIT IF
° EXIT FOR
° EXIT FUNCTION
° EXIT SUB
° EXIT SELECT
° NEXT CASE
Execution need not proceed linearly through blocks. DO xxx and EXIT xxx statements control the execution path through blocks. For example, it is perfectly acceptable to do the next iteration of a DO loop by executing a DO DO or DO LOOP statement, even if there are other blocks between the ends of the DO block and the DO DO or DO LOOP.
Multi-level DO xxx # and EXIT xxx # statements are provided. For example, EXIT DO 2 escapes two levels of DO loops instead of just one, DO DO 3 jumps to the DO statement three levels back, and DO LOOP 1 is the same as DO LOOP.
If you modify code near multi-level statements, be careful to adjust the # level counts as necessary.