Mel - Maya Embedded Language

<HOME>   <PREVIOUS>   <NEXT>

Loops and If Blocks - for in loop

if then else
for
for in
while
do while
switch

for in

This is an alternate for statement you can use.
int $Vals[ ] = {1, 2, 3, 4, 5};
int $elements;
//this will repeat for each element in the array
for($elements in $Vals)
{
     print ("\nYou are reading element "+ $elements+" of Vals.");
}
The loop should return:
You are reading element 1 of Vals.
You are reading element 2 of Vals.
You are reading element 3 of Vals.
You are reading element 4 of Vals.
You are reading element 5 of Vals.