Mel - Maya Embedded Language

for

The for loop is mainly used to run commands on the values of an array.
A for loop mainly consists of:

for(initial execution; test condition; execute after each loop) {operation;}

string $myArray [] = {"one","two","three","four"};
int $myArraySize = size($myArray);
for ($i =0; $i<$myArraySize; $i++)
{
	if ($myArray[$i] == "one")
		print ("\n"+$myArray[$i] + " dead roach!");
	else
		print ("\n"+$myArray[$i] + " dead roaches!");
}
returns:

one dead roach!
two dead roaches!
three dead roaches!
four dead roaches!

In this example I included an imbedded funcion of mayas called size(). When you want to find the size of a given array use size(arrayname);. This comes in handy in situations such as the one above. We have an array, we are not sure the size of the array, but we want a loop to happen based on the size of that array.