Back to OmaTips

Looping Loops
Why would you want to loop a loop? Well mostly when you want to increment a process, and within that process you need to increment something else as well.

The easiest example, MM related, that I can think of is for "walking" arrays. Say you have an array, MyArray, that is 2 rows and 5 columns. You just want to make some showmes that'll spew out each cells info.

We know it's 2 rows, so our first loop will be only {1,2} (for rows 1, then 2).
We know it's 5 columns so our second (imbedded) loop will be {1,5}.

And we can rename the loopcount variable to anything we want, and we must do that when imbedding loops. So, we do something like:

/loop {1,2,LoopOne} {/loop {1,5,LoopTwo} {/showme {@GetArray(MyArray,$LoopOne,$LoopTwo)}}}

Simple!