To begin you would want to create a trigger such as start of layout, located under the system object. Then you would create a sub event under that, a nested loop. This would be a for loop, again located under the system, I would name it "x", as per my example. To nest it, add another subevent, another for loop, "y".
Then, once more you add a sub event under that, this will be a comparison.
The array object has one built in, or you can use the system compare.
Named for loops can be referred to in expressions as loopindex("loopname"). So if you input loopindex("x") in your comparison it will use the value of the current loop, 0,1,2,3,4, etc.
There are tons of examples that come with C2, and much more on the forums.
Might want to look around, its an excellent resource.