WMLScript » Statements » break

Syntax:
break

The break statement is used to terminate the execution of a for or while loop statement. All processing is immediately stopped inside the loop and the loop is exited. The program continues with the first line of code (if any) after the terminated loop.

Attempting to use a break statement outside of a for or while loop statement will generate an error.

Examples

Code:
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.WAPforum.org/DTD/wml_1.1.xml">
<wml>

<card id="card1">
   <p>
   break example
   </p>
   <do type="accept">
      <go href="BreakExample.wmls#findbreak()" />
   </do>
</card>

<card id="card2">
<p>
   count reached $(count)
</p>
</card>

</wml>
Explanation:

Code for BreakExample.wml

Language(s): WML
Code:
extern function findbreak()
{
   var count = 0;
   while(count < 10)
   {
   var rand = Lang.random(10);
      if(rand > 5)
      {
         count++;
         continue;
      }
      if(rand < 5)
      {
         count--;
         continue;
      }
      if(rand == 5)
      {
         break;
      }
   }
   WMLBrowser.setVar("count", count);
   WMLBrowser.go("BreakExample.wml#card2");
};
Explanation:

Code for BreakExample.wmls

Language(s): WML

See Also: