Ends the current code and returns control to the caller.
The Lang.exit function is used to
perform a normal exit from a WMLScript program. The execution of the
WMLScript code is discontinued, control is returned to the caller of
the WMLS program, and the information contained in the value
parameter is returned to the WMLS interpretor. Simply put, you use this
function to exit a WMLS function and return to the calling WML card.
<?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>
exit
example
</p>
<do type="accept">
<go
href="ExitExample.wmls#exittest( )" />
</do>
</card>
<card id="card2">
<p>
random number
<br
/>
$(randomnum)
</p>
</card>
</wml>Code for ExitExample.wml
extern function exittest()
{
var result = Lang.random(100);
if(result < 50)
{
Lang.exit("");
}
else
{
WMLBrowser.setVar("randomnum",
result);
WMLBrowser.go("ExitExample.wml#card2");
}
};
In this example, the Lang.random function is used to return a random integer ranging from 0 to 100 in value. A simple if...else test on the value of the random number either returns control to card two or performs an exit which returns control back to card one.