Mel - Maya Embedded Language


Loops and If Blocks - do while loop

if then else
for in
do while

do while

The do-while loop runs a command while the test condition is true
A do-while loop mainly consists of:

     do something;
while (test condition);

string $myArray [ ] = {"one","two","three","four"};
int $i =0;
     if ($myArray[$i] == "one")
          print ("\n"+$myArray[$i] + " dead roach!");
          print ("\n"+$myArray[$i] + " dead roaches!");
     $i++; //do not forget this or Maya will get stuck in an infinite loop
while ( $i < size($myArray));

Exercise: Create a sphere then duplicate it, then move it by 1.5 along the X.
Use a do while loop to duplicate it using the smartTransform flag. Exit the loop when the X position exceeds 20.