Skip to main content
U.S. flag

An official website of the United States government

Official websites use .gov
A .gov website belongs to an official government organization in the United States.

Secure .gov websites use HTTPS
A lock ( ) or https:// means you’ve safely connected to the .gov website. Share sensitive information only on official, secure websites.

Nested Loops

Loops can be nested to define more complex measurements.  Nesting is accomplished by placing one loop inside another and iterating through that one loop completely for every iteration in the other loop.

Nested Loops Reference Example 1

When nesting, only the innermost (leaf) loop contains points, while the outer loop(s) just move through measurement states without counting.

Nested Loops Reference Example 2

Note: Unlike with sub-loops, nested loops require that you open a loop block that is a level of indentation deeper than the preceding loop. Every time you wish to embed another loop inside a given loop, you must indent another level.

Created December 10, 2018