Keywords

This chapter constains a list of keywords.

if

It defines a condition. Its form is:


if(expr)    
{
}

if(expr)
  expr2;    

expr - must evaluate to Int value, where 0 means false, other value is treated as true and the condition body is executed. expr2 is an expresion that is executed when expr is true and the block is not specified.


Int x = 5;
if(x)    //cast to boolean value ok
{
  x++;  //executed
}

if(x == 7)    //boolean value false
{
  x++;  //not executed
}  

else

Optional code executed when the condition fails. It must follow an if statement:


if(expr)
{
}
else    
{
}

if(expr)
  expr2;
else
  expr3;    


Int x = 5;
if(x < 0)    // boolean value false
{
  x++;       // not executed
}
else
if(x > 0)    //boolean value true
  x--;       //executed
else
{
  x = 20;
}


while

Defines a loop, done until the condition is true.


while(expr)
{
}

while(expr)
  expr2;

The above loop will be done until expr evaluates to value not equal 0. expr must evaluate to Bool.


Int x = 5;
while(x < 10)    // done 5 times
{
  x++;          
}


for

for loop, similar to C++ for.


for(expr1; expr2; expr3)
{
}

for(expr1; expr2; expr3)
   expr4;

expr1 - done before execution of the loop body, may define variables.

expr2 - condition - if this value is evaluated to 0 , the loop ends

expr3 - done after every iteration

All above expression are optional.


Int y = 0;
for(Int i = 0; i<10; i++)    // done 10 times, y=20 when finishes
{
   y += 2;                   
}


for(;;)                      //infinite loop
{
}


break

Finishes the loop that body it is placed in.


Int y = 0;
for(Int i = 0; i<10; i++)    // done 10 times, y=20 when finishes
{
   y += 2;
   if(y >= 10)               //breaks loop in 5 iteration
     break;                   
}


continue

Executes the next iteration of the loop that body it is placed in.


Int y = 0;
for(Int i = 0; i<10; i++)    // done 10 times, y=18 when finishes
{
   if(i == 5)               //skips  5 iteration
     continue;
   y += 2;                      
}


static

Modifies a variable type, see the static variables chapter. The variable is initialized only once in the script lifetime.

shared

Modifies a variable type, see sthe shared variables chapter. The variable may be shared between scripts.

const

Modifies a variable type. The variable value cannot be changed after initialization.