May 5, 2014

"continue" and "break" statements in X++



// Sample job using "continue" and "break" statements in X++
Static void sampleContinueBreak()
{
  int counter;
  
for (counter=1;counter <= 10;counter++)

  {           
     if (counter > 3 && counter < 8)

     {
       continue;

     }
     else if(counter == 9)

     {
        break;

     }
     info(int2str( counter));


  }
 
 info(int2str( counter));
   
}


//One more example

static int sampleSwitch(int x = 5)
{
 ; 

 switch (x)
 { 

  case (1):
  x = 5;

  case (5):
  x = x + 5;

  case (10):
  x = x + 10;
  break;

  case (20):
  x = x + 20;
  break;

  default:
  x = 5;


 }
info(strfmt("Return value is %1", x));
return x;

}







No comments: