4.13 For Next Loops

For Next Loops give you the ability to execute a statement over and over again, until a defined condition
is reached.

A for loop has this format:

for ( initialization; condition; change of condition )

{
statement;
statement;
...
}

A for loop evaluates the termination condition before executing each statement . The condition compares
variable, attribute, or constant values.

Example for string variables and For Next Loops.

for ( i = 1; i <= 100; i = i + 1 ) // start with i = 1, as long as i <= 100, do i = i + 1 at end

{

$object = "Block_copy_" + i; // this renumbers Block_copy_x each time the loop is executed

if ( frame + 1 == i ) // this sets the the visibility of Block_copy_1 to 0 on frame 2 if i = 1

{
$object.Visibility = 0;
}

else // on all other frames the visibility of $object is 1

{
$object.Visibility = 1;
}

};

Each time the loop executes again it will be executed for the next Cube_copy_ object. It starts with Cube_copy_1
if i = 1. If i = 2 it will be executed for Cube_copy_2 and so on until Cube_copy_100 is reached and than stop.
Since i also changes in the number of the frame for the visibility switch the expression will switch off the visibility
of the different cubes also on different frames, resulting in a flowing behavior in the visibility switching of the objects.

get project 100_cubes.prj

Xpressionist 3.5