Flow control

The following script presents basic flow control operators, which are similar to these known from C and other popular languages.

//if-else
if (true)
  echo("ok");
//prints "ok"  
if (false)
  echo ("ok")//notice lack of separator after instruction
else
  echo("ko");//separator is only here
//prints "ko"
//for 
for (var x = 2; x < 40;x += 10)
  echo(x);
//prints: 2 12 22 32
//while 
var x = 2;
while (x < 40)
{
  x += 10;
  echo(x);
}
//prints 12 22, 32, 42
//loop - equivalent to while(1)
loop
{
  echo("From loop");
  sleep(1);
},
//prints "From loop" every 1s until you kill the Urbi engine
//switch - notice that switch do not requires breaks after every case
switch("bar")
{
  case "foo": 0;
  case "bar": 1;
  case "bax": 2;
  case "qux": 3;
};
//returns 1

More examples you can find in the URBI documentation LINK.

 

 

EMYS and FLASH are Open Source and distributed according to the GPL v2.0 © Rev. 0.8.0, 27.04.2016

FLASH Documentation