for statement
continue statement
if statement
while statement
STATEMENT: break
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.
Code for BreakExample.wml
<?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>
Code for BreakExample.wmls
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");
};
Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information