Blockland Wiki
Advertisement

The for keyword is a looping construct whose general form is:

for (expression 0 ; expression1 ; expression2 )

{
statement (s);
}
  • expression0 - usually of the form: variable = value
  • expression1 - usually of the form: variable compare op value
  • expression2 - usually of the form: variable op OR variable op value

The loop continues to execute statement(s) until expression0 evaluates to zero.

Note: expression0, expression1, and expression2 are all required. If you absolutely need expression0 or expression2 to be empty just insert a 0.

Note2: Composite expressions of the form ( sub_expression0, sub_expression1 , _ sub_expressionN ) are illegal.

//Example 1
for( %val = 0 ; %val < 3 ; %val++ )
{
echo( %val );
}

For

//Example 2 - 'Empty' expression 0 and 2
%value = 0;
for (0; %val < 3; 0 )
{
echo ( %val );
%val ++;
}

For

//Example 3 - Illegal sub-expressions
//This would produce an error while 'compiling'
%val = 0;
for ( %val0 = 0 , %val1 = 3 ; %val0 < 3 ; %val0++, %val1-- )
{
echo ( %val0 );
echo ( %val1 );
}

For

See Also[]

Advertisement